GraphQL.QueryRegistry (GraphQL Client v0.2.0) View Source

Functions to handle query registries.

A query registry stores several GraphQL.Query structs, so they can be combined into a single query before the execution.

Link to this section Summary

Types

A resolver is a function that must accept two arguments

t()

A struct that keeps the information about several queries, variables and resolvers.

Functions

Add a query to the a query registry

Add a new resolver into a query registry

Add a list of resolvers into a query registry

Executes the given query registry, using the given accumulator acc and the given options

Creates a new QueryRegistry struct with the given name.

Link to this section Types

Specs

resolver() :: (Response.t(), any() -> any())

A resolver is a function that must accept two arguments:

It also must return the updated value of the accumulator.

Specs

t() :: %GraphQL.QueryRegistry{
  name: String.t(),
  queries: [GraphQL.Query.t()],
  resolvers: list(),
  variables: [map()]
}

A struct that keeps the information about several queries, variables and resolvers.

The name field will be used as the name of the final query or mutation.

The queries field is a list of GraphQL.Query structs, that will be merged before execution.

The variables is a map with all values of variables that will be sent to the server along with the GraphQL body.

The resolver is a list of t:resolver() functions that can be used to produce the side effects in an accumulator.

Link to this section Functions

Link to this function

add_query(registry, query, variables \\ nil)

View Source

Specs

add_query(t(), GraphQL.Query.t(), map()) :: t()

Add a query to the a query registry

Link to this function

add_resolver(registry, function)

View Source

Specs

add_resolver(t(), resolver()) :: t()

Add a new resolver into a query registry

Link to this function

add_resolvers(registry, resolvers)

View Source

Specs

add_resolvers(t(), [resolver()]) :: t()

Add a list of resolvers into a query registry

Link to this function

execute(registry, acc, options \\ [])

View Source

Specs

execute(t(), any(), Keyword.t()) :: any()

Executes the given query registry, using the given accumulator acc and the given options

Specs

new(String.t()) :: t()

Creates a new QueryRegistry struct with the given name.