Skip to content

Instantly share code, notes, and snippets.

@bruce
Created July 17, 2017 16:12
Show Gist options
  • Save bruce/7dad75d8559cd02dcacd3f944ec663ab to your computer and use it in GitHub Desktop.
Save bruce/7dad75d8559cd02dcacd3f944ec663ab to your computer and use it in GitHub Desktop.
Simple example of a field result being returned as a GraphQL type
mutation do
field :create_foo, :create_foo_result do
resolve fn _, _ ->
# Return an :ok w/ a :create_foo_result
# containing a `foo` and/or `errors`
end
end
end
@desc "The result of creating a Foo"
object :create_foo_result do
field :foo, :foo
field :errors, list_of(:input_error)
end
@desc "An error encountered trying to persist input"
object :input_error do
field :key, non_null(:string)
field :message, non_null(:string)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment