Skip to content

Instantly share code, notes, and snippets.

@bruce
Created January 10, 2017 17:15
Show Gist options
  • Save bruce/e1e927c5130a850f26e29b5fbdc1b897 to your computer and use it in GitHub Desktop.
Save bruce/e1e927c5130a850f26e29b5fbdc1b897 to your computer and use it in GitHub Desktop.
Example resolver helper for pulling data from another source field
defmodule ExampleSchema do
use Absinthe.Schema
# rest of schema
object :message do
field :date, :datetime do
resolve source_field(:inserted_at)
end
end
def source_field(name) do
fn source, _, _ ->
{:ok, Map.get(source, name)}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment