Created
January 9, 2017 05:45
-
-
Save bruce/0ca5c05d828253306559616460410e0a to your computer and use it in GitHub Desktop.
Example creation/update
This file contains 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 MyApp.Schema do | |
use Absinthe.Schema | |
mutation do | |
field :create_user, :user do | |
arg :input, :user_creation | |
resolve fn | |
_, %{input: input}, _ -> | |
# create from `input`, assign `user` | |
{:ok, user} | |
end | |
end | |
field :update_user, :user do | |
arg :id, :id | |
arg :input, :user_change | |
resolve fn | |
_, %{id: id, input: input}, _ -> | |
# lookup from `id`, update from `input`, assign `user` | |
{:ok, user} | |
end | |
end | |
end | |
object :user do | |
field :id, :id | |
field :name, :string | |
end | |
input_object :user_creation do | |
field :name, :string | |
field :email, :string | |
end | |
input_object :user_change do | |
field :name, :string | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment