在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):graphql-elixir/graphql开源软件地址(OpenSource Url):https://github.com/graphql-elixir/graphql开源编程语言(OpenSource Language):Elixir 95.5%开源软件介绍(OpenSource Introduction):GraphQL ElixirAn Elixir implementation of Facebook's GraphQL. This is the core GraphQL query parsing and execution engine whose goal is to be transport, server and datastore agnostic. In order to setup an HTTP server (ie Phoenix) to handle GraphQL queries you will need plug_graphql. Examples for Phoenix can be found at hello_graphql_phoenix, so look here for a starting point for writing your own schemas. Other ways of handling queries will be added in due course. InstallationFirst, add GraphQL to your defp deps do
[{:graphql, "~> 0.3"}]
end Add GraphQL to your def application do
# Add the application to your list of applications.
# This will ensure that it will be included in a release.
[applications: [:logger, :graphql]]
end Then, update your dependencies: $ mix deps.get UsageFirst setup your schema defmodule TestSchema do
def schema do
%GraphQL.Schema{
query: %GraphQL.Type.ObjectType{
name: "RootQueryType",
fields: %{
greeting: %{
type: %GraphQL.Type.String{},
resolve: &TestSchema.greeting/3,
description: "Greeting",
args: %{
name: %{type: %GraphQL.Type.String{}, description: "The name of who you'd like to greet."},
}
}
}
}
}
end
def greeting(_, %{name: name}, _), do: "Hello, #{name}!"
def greeting(_, _, _), do: "Hello, world!"
end Execute a simple GraphQL query iex> GraphQL.execute(TestSchema.schema, "{greeting}")
{:ok, %{data: %{"greeting" => "Hello, world!"}}} StatusThis is a work in progress, right now here's what is done:
Resources
ImplementationTokenisation is done with leex and parsing with yecc. Both very useful Erlang tools for parsing. Yecc in particular is used by Elixir itself. Some resources on using leex and yecc:
The Execution logic follows the GraphQL JS Reference Implementation pretty closely, as does the module structure of the project. Not to mention the naming of files and concepts. If you spot anything that isn't following Elixir conventions though, that's a mistake. Please let us know by opening an issue or a PR and we'll fix it. DevelopersGetting StartedClone the repo and fetch its dependencies:
Atom Editor Support
Syntax highlighting in Atom for Just open the jonathanmarvens/atom-language-erlang#11 however if that PR has been merged then just grab the latest version of the plugin! ContributingWe actively welcome pull requests, bug reports, feedback, issues, questions. Come and chat in the #erlang channel on Slack If you're planning to implement anything major, please let us know before you get too far so we can make sure your PR will be as mergable as possible. Oh, and don't forget to write tests. LicenseBSD. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论