Speakeasy.LoadResourcePassParent (Speakeasy v0.3.2)

A convienence middleware to LoadResource using the parent in the Absinthe resolver.

See the README for a complete example in a Absinthe Schema.

Link to this section Summary

Functions

This calls LoadResource under the hood and extracts the resource from the parent.

Link to this section Functions

Link to this function

call(resolution, opts)

This calls LoadResource under the hood and extracts the resource from the parent.

Examples

object :user do
  field :id, non_null(:id)
  field :name, :string
  field :private_things, :secret_data do
    middleware(Speakeasy.Authn)
    middleware(Speakeasy.LoadResourcePassParent)
    middleware(Speakeasy.Authz, {Users, :read_private_things})
    middleware(Speakeasy.Resolve, fn user, _, _ -> {:ok, user.private_things} end)
  end
end