GraphqlQuery.MacroOptions (graphql_query v0.6.2)

View Source

Options for the different macros in the GraphqlQuery module.

• :ignore (boolean()) - Ignore validation errors The default value is false.

• :type (:query | :schema | :fragment) - Type of the GraphQL document, either :query or :schema The default value is :query.

• :schema (module()) - Module that provides the GraphQL schema The default value is nil.

• :evaluate (boolean()) - Try to evaluate dynamic parts of the document The default value is false.

• :runtime (boolean()) - Use runtime evaluation for the GraphQL query The default value is false.

• :federation (boolean()) - Enable Apollo Federation v2 directive support for schema validation The default value is false.

Summary

Functions

Returns documentation string for available macro options.

Validates macro options against the schema.

Validates macro options against the schema, raising on error.

Types

t()

@type t() :: %GraphqlQuery.MacroOptions{
  evaluate: boolean() | nil,
  federation: boolean() | nil,
  format: boolean() | nil,
  fragments: [GraphqlQuery.Fragment.t()],
  ignore: boolean() | nil,
  runtime: boolean() | nil,
  schema: module() | nil,
  type: :query | :schema | :fragment
}

Functions

docs()

@spec docs() :: String.t()

Returns documentation string for available macro options.

Provides detailed documentation for all configuration options that can be passed to GraphQL macros.

Examples

iex> docs = GraphqlQuery.MacroOptions.docs()
iex> is_binary(docs)
true

to_keyword(opts)

validate(opts)

@spec validate(Keyword.t()) :: {:ok, t()} | {:error, term()}

Validates macro options against the schema.

Validates and normalizes options for GraphQL macros, returning either a valid options struct or an error.

Examples

iex> {:ok, opts} = GraphqlQuery.MacroOptions.validate([type: :query, ignore: true])
iex> opts.type
:query
iex> opts.ignore
true

iex> {:error, _reason} = GraphqlQuery.MacroOptions.validate([ignore: "invalid"])

validate!(opts)

@spec validate!(Keyword.t()) :: t() | no_return()

Validates macro options against the schema, raising on error.

Like validate/1 but raises an ArgumentError if validation fails.

Examples

iex> opts = GraphqlQuery.MacroOptions.validate!([type: :fragment])
iex> opts.type
:fragment