Apq v1.1.1 Apq.DocumentProvider View Source

Apq document provider or Absinthe plug.

Example

Define a new module and use Apq.DocumentProvider:

defmodule ApqExample.Apq do
  use Apq.DocumentProvider,
    cache_provider: ApqExample.Cache,
    max_query_size: 16384 #default

end

Options

  • :cache_provider — Module responsible for cache retrieval and placement. The cache provider needs to follow the Apq.CacheProvider behaviour.
  • :max_query_size — (Optional) Maximum number of bytes of the graphql query document. Defaults to 16384 bytes (16kb)

Example configuration for using Apq in Absinthe.Plug. Same goes for configuring Phoenix.

match("/api",
  to: Absinthe.Plug,
  init_opts: [
    schema: ApqExample.Schema,
    json_codec: Jason,
    interface: :playground,
    document_providers: [ApqExample.Apq, Absinthe.Plug.DocumentProvider.Default]
  ]
)

When the Apq document provider does not match (i.e. the apq extensions are not set in the request), the request is passed to the next document provider. This will most likely by the default provider available (Absinthe.Plug.DocumentProvider.Default).