Permit.Absinthe.Schema.Prototype (permit_absinthe v0.3.1)

Copy Markdown View Source

Prototype schema for Absinthe.

This module defines the :load_and_authorize directive, which is used to authorize fields in the schema.

Usage

Add the prototype schema to your schema:

defmodule MyAppWeb.Schema do
  use Absinthe.Schema

  @prototype_schema Permit.Absinthe.Schema.Prototype

  # Your schema definition...

  query do
    field :items, list_of(:item), directives: [:load_and_authorize] do
      permit(action: :read)

      resolve(fn _, %{context: %{loaded_resources: items}} ->
        {:ok, items}
      end)
    end
  end
end

Summary

Functions

Add a deprecation (with an optional reason) to a node.

Functions

expand_deprecate(arguments, node)

@spec expand_deprecate(
  arguments :: %{optional(:reason) => String.t()},
  node :: Absinthe.Blueprint.node_t()
) :: Absinthe.Blueprint.node_t()

Add a deprecation (with an optional reason) to a node.

pipeline(pipeline)