zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

default.ex (1587B)


      1 defmodule Absinthe.Plug.DocumentProvider.Default do
      2   @moduledoc """
      3   This is the default document provider, implementing the
      4   `Absinthe.Plug.DocumentProvider` behaviour.
      5 
      6   This document provider will handle any document that's provided:
      7 
      8   - As the body of an HTTP POST with content-type `application/graphql`
      9   - As the parsed `"query"` parameter in an HTTP POST of content-type `application/json`
     10   - As the `"query"` parameter in an HTTP GET query string
     11 
     12   (Note that the parsing itself happens in `Absinthe.Plug.Parser` /
     13   `Absinthe.Plug`; this document provider just knows how to work with the
     14   value.)
     15 
     16   ## Configuring
     17 
     18   By default, this is the only document provider configured by `Absinthe.Plug.init/1`.
     19 
     20   Using the `:document_providers` option, however, you can:
     21 
     22   - Add additional document providers to expand the ways that documents can be loaded.
     23     See, for example, `Absinthe.Plug.DocumentProvider.Compiled`.
     24   - Remove this document provider from the configuration to disallow ad hoc queries.
     25 
     26   See the documentation on `Absinthe.Plug.init/1` for more details on the
     27   `:document_providers` option.
     28 
     29   """
     30 
     31   @behaviour Absinthe.Plug.DocumentProvider
     32 
     33   @doc false
     34   @spec pipeline(Absinthe.Plug.Request.Query.t()) :: Absinthe.Pipeline.t()
     35   def pipeline(%{pipeline: as_configured}), do: as_configured
     36 
     37   @doc false
     38   @spec process(Absinthe.Plug.Request.Query.t(), Keyword.t()) ::
     39           Absinthe.Plug.DocumentProvider.result()
     40   def process(%{document: nil} = query, _), do: {:cont, query}
     41   def process(%{document: _} = query, _), do: {:halt, query}
     42 end