Created
January 4, 2017 20:51
-
-
Save bruce/9bec46f02e0292484744935c6ff98d66 to your computer and use it in GitHub Desktop.
Comparing absinthe schema definition to graphql-elixir schema definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule TestSchema do | |
| use Absinthe.Schema | |
| query do | |
| @desc "A Greeting" | |
| field :greeting, :string do | |
| @desc "The name of who you'd like to greet" | |
| arg :name, :string | |
| resolve &greeting/3 | |
| end | |
| end | |
| defp greeting(_, %{name: name}, _), do: {:ok, "Hello, #{name}!"} | |
| defp greeting(_, _, _), do: {:ok, "Hello, world!"} | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment