View Source AbsinthePlugCache.Plug.DocumentProvider behaviour (absinthe_plug_cache v1.5.8-1)

A document provider is a module that, given a GraphQL query, determines what document should be executed and how the configured pipeline should be applied to that document.

configuring

Configuring

Configuration of your document providers occurs on initialization of AbsinthePlugCache.Plug; see that module's documentation of the :document_providers option for more details.

making-your-own

Making Your Own

AbsinthePlugCache.Plug.DocumentProvider is a behaviour, and any module that implements its callbacks can function as a document provider for AbsinthePlugCache.Plug.

See the documentation for the behaviour callbacks and the implementation of the document providers that are defined in this package for more information.

Link to this section Summary

Types

When the request is not handled by this document provider (so processing should continue to the next one)

t()

A configuration for a document provider, which can take two forms

Callbacks

Given a request, determine what part of its configured pipeline should be applied during execution.

Given a request, attempt to process it with this document provider.

Link to this section Types

@type result() ::
  {:halt, AbsinthePlugCache.Plug.Request.Query.t()}
  | {:cont, AbsinthePlugCache.Plug.Request.Query.t()}

When the request is not handled by this document provider (so processing should continue to the next one):

{:cont, AbsinthePlugCache.Plug.Request.Query.t}

When the request has been processed by this document provider:

{:halt, AbsinthePlugCache.Plug.Request.Query.t}

Note that if no document providers set the request document, no document execution will occur and an error will be returned to the client.

@type t() :: module() | {module(), Keyword.t()}

A configuration for a document provider, which can take two forms:

  • module when options do not need to be passed to the document provider.
  • {module, Keyword.t} when options are needed by the document provider.

Link to this section Callbacks

@callback pipeline(AbsinthePlugCache.Plug.Request.Query.t()) :: Absinthe.Pipeline.t()

Given a request, determine what part of its configured pipeline should be applied during execution.

@callback process(AbsinthePlugCache.Plug.Request.Query.t(), Keyword.t()) :: result()

Given a request, attempt to process it with this document provider.

return-types

Return Types

See the documentation for the AbsinthePlugCache.Plug.DocumentProvider.result type.