View Source Absinthe.Pipeline (absinthe v1.7.5)

Execute a pipeline of phases.

A pipeline is merely a list of phases. This module contains functions for building, modifying, and executing pipelines of phases.

Pipelines are used to build, validate and manipulate GraphQL documents or schema's.

  • See Absinthe.Plug on adjusting the document pipeline for GraphQL over http requests.
  • See Absinthe.Phoenix on adjusting the document pipeline for GraphQL over Phoenix channels.
  • See Absinthe.Schema on adjusting the schema pipeline for schema manipulation.

Link to this section Summary

Functions

Return the part of a pipeline before a specific phase.

The default document pipeline

The default schema pipeline

Return the part of a pipeline after (and including) a specific phase.

Return the pipeline with the phase/list of phases inserted after the supplied phase.

Return the pipeline with the phase/list of phases inserted before the supplied phase.

Return the pipeline with the phases matching the regex removed.

Replace a phase in a pipeline with another, supporting reusing the same options.

Return the part of a pipeline up to and including a specific phase.

Return the pipeline with the supplied phase removed.

Link to this section Types

Link to this section Functions

@spec before(t(), phase_config_t()) :: t()

Return the part of a pipeline before a specific phase.

examples

Examples

iex> Pipeline.before([A, B, C], B)
[A]
Link to this function

default_schema_options()

View Source
Link to this function

for_document(schema, options \\ [])

View Source
@spec for_document(Absinthe.Schema.t(), Keyword.t()) :: t()

The default document pipeline

Link to this function

for_schema(schema, options \\ [])

View Source
@spec for_schema(nil | Absinthe.Schema.t(), Keyword.t()) :: t()

The default schema pipeline

@spec from(t(), atom()) :: t()

Return the part of a pipeline after (and including) a specific phase.

examples

Examples

iex> Pipeline.from([A, B, C], B)
[B, C]
Link to this function

insert_after(pipeline, phase, additional)

View Source
@spec insert_after(t(), Absinthe.Phase.t(), phase_config_t() | [phase_config_t()]) ::
  t()

Return the pipeline with the phase/list of phases inserted after the supplied phase.

examples

Examples

Add one phase after another:

iex> Pipeline.insert_after([A, C, D], A, B)
[A, B, C, D]

Add list of phases after another:

iex> Pipeline.insert_after([A, D, E], A, [B, C])
[A, B, C, D, E]
Link to this function

insert_before(pipeline, phase, additional)

View Source
@spec insert_before(t(), Absinthe.Phase.t(), phase_config_t() | [phase_config_t()]) ::
  t()

Return the pipeline with the phase/list of phases inserted before the supplied phase.

examples

Examples

Add one phase before another:

iex> Pipeline.insert_before([A, C, D], C, B)
[A, B, C, D]

Add list of phase before another:

iex> Pipeline.insert_before([A, D, E], D, [B, C])
[A, B, C, D, E]
Link to this function

options(overrides \\ [])

View Source
Link to this function

reject(pipeline, pattern)

View Source
@spec reject(t(), Regex.t() | (module() -> boolean())) :: t()

Return the pipeline with the phases matching the regex removed.

examples

Examples

iex> Pipeline.reject([A, B, C], ~r/A|B/)
[C]
Link to this function

replace(pipeline, phase, replacement)

View Source
@spec replace(t(), Absinthe.Phase.t(), phase_config_t()) :: t()

Replace a phase in a pipeline with another, supporting reusing the same options.

examples

Examples

Replace a simple phase (without options):

iex> Pipeline.replace([A, B, C], B, X)
[A, X, C]

Replace a phase with options, retaining them:

iex> Pipeline.replace([A, {B, [name: "Thing"]}, C], B, X)
[A, {X, [name: "Thing"]}, C]

Replace a phase with options, overriding them:

iex> Pipeline.replace([A, {B, [name: "Thing"]}, C], B, {X, [name: "Nope"]})
[A, {X, [name: "Nope"]}, C]
@spec run(data_t(), t()) ::
  {:ok, data_t(), [Absinthe.Phase.t()]}
  | {:error, String.t() | {:http_method, String.t()}, [Absinthe.Phase.t()]}
Link to this function

run_phase(pipeline, input, done \\ [])

View Source
@spec run_phase(t(), data_t(), [Absinthe.Phase.t()]) ::
  {:ok, data_t(), [Absinthe.Phase.t()]}
  | {:error, String.t() | {:http_method, String.t()}, [Absinthe.Phase.t()]}
@spec upto(t(), phase_config_t()) :: t()

Return the part of a pipeline up to and including a specific phase.

examples

Examples

iex> Pipeline.upto([A, B, C], B)
[A, B]
Link to this function

without(pipeline, phase)

View Source
@spec without(t(), Absinthe.Phase.t()) :: t()

Return the pipeline with the supplied phase removed.

examples

Examples

iex> Pipeline.without([A, B, C], B)
[A, C]