Skip to content

Instantly share code, notes, and snippets.

@bruce
Created January 9, 2017 05:45
Show Gist options
  • Save bruce/0ca5c05d828253306559616460410e0a to your computer and use it in GitHub Desktop.
Save bruce/0ca5c05d828253306559616460410e0a to your computer and use it in GitHub Desktop.
Example creation/update
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