absinthe v1.2.3 Absinthe.Resolution.Plugin.Async
This plugin enables asynchronous execution of a field.
See also Absinthe.Resolution.Helpers.async/1
Example Usage:
Using the Absinthe.Resolution.Helpers.async/1
helper function:
field :time_consuming, :thing do
resolve fn _, _, _ ->
async(fn ->
{:ok, long_time_consuming_function()}
end)
end
end
Using the bare plugin API
field :time_consuming, :thing do
resolve fn _, _, _ ->
task = Task.async(fn ->
{:ok, long_time_consuming_function()}
end
{:plugin, Elixir.Absinthe.Resolution.Plugin.Async, task}
end
end
This module also serves as an example for how to build a basic resolution plugin. See the source code and associated comments for further details.
Summary
Functions
Callback implementation for Absinthe.Resolution.Plugin.after_resolution/1
Callback implementation for Absinthe.Resolution.Plugin.before_resolution/1
Callback implementation for Absinthe.Resolution.Plugin.init/2
Callback implementation for Absinthe.Resolution.Plugin.pipeline/2
Functions
Callback implementation for Absinthe.Resolution.Plugin.after_resolution/1
.
Callback implementation for Absinthe.Resolution.Plugin.before_resolution/1
.
Callback implementation for Absinthe.Resolution.Plugin.init/2
.
Callback implementation for Absinthe.Resolution.Plugin.pipeline/2
.