absinthe v1.2.0-rc.0 Absinthe.Resolution.Helpers
Handy functions for returning async or batched resolution functions
It is automatically imported into all modules using Absinthe.Schema.Notation
or (by extension) Absinthe.Schema.
Summary
Functions
Execute resolution field asynchronously
Batch the resolution of several functions together
Functions
async(fun, opts \\ [])
async((() -> term), Keyword.t) :: {:plugin, Absinthe.Resolution.Plugin.Async, term}
Execute resolution field asynchronously.
This is a helper function for using the Absinthe.Resolution.Plugin.Async.
Forbidden in mutation fields. (TODO: actually enforce this)
batch(batch_fun, batch_data, post_batch_fun, opts \\ [])
batch(Absinthe.Resolution.Plugin.Batch.batch_fun, term, Absinthe.Resolution.Plugin.Batch.post_batch_fun, opts :: Keyword.t) :: {:plugin, Absinthe.Resolution.Plugin.Batch, term}
Batch the resolution of several functions together.
Helper function for creating Absinthe.Resolution.Plugin.Batch
Example
Raw usage:
object :post do
field :title, :string
field :body, :string
field :author, :user do
resolve fn post, _, _ ->
batch({EctoBatch, :by_id}, {User, post.author_id}, fn batch_results ->
{:ok, batch_results[User][post.author_id]}
end)
end
end
end
field
resolve fn post, _, _
batch({EctoBatch, :by_id}, [])