Apq.DocumentProvider (Apq v2.0.0) 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 theApq.CacheProvider
behaviour.:max_query_size
-- (Optional) Maximum number of bytes of the graphql query document. Defaults to 16384 bytes (16kb).:json_codec
-- (Optional) Only required if using GET for APQ's hashed queries. Must respond todecode!/1
.:strategy
-- Strategy whether to cache raw graphql strings, or the parsed/validated blueprint. Defaults to raw.
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
).
Link to this section Summary
Functions
Determine the remaining pipeline for a request with an apq document.
Handles any requests with the Apq extensions and forwards those without to the next document provider.
Link to this section Functions
Determine the remaining pipeline for a request with an apq document.
Handles any requests with the Apq extensions and forwards those without to the next document provider.