Created
July 17, 2017 16:12
-
-
Save bruce/7dad75d8559cd02dcacd3f944ec663ab to your computer and use it in GitHub Desktop.
Simple example of a field result being returned as a GraphQL type
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
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