absinthe v1.4.13 Absinthe View Source

Documentation for the Absinthe package, a toolkit for building GraphQL APIs with Elixir.

For usage information, see the documentation, which includes guides, API information for important modules, and links to useful resources.

Link to this section Summary

Functions

Evaluates a query document against a schema, without options

Evaluates a query document against a schema, with options

Link to this section Types

Link to this type result_error_t() View Source
result_error_t() ::
  %{message: String.t()}
  | %{message: String.t(), locations: [%{line: integer(), column: integer()}]}
Link to this type result_selection_t() View Source
result_selection_t() :: %{
  optional(String.t()) =>
    nil
    | integer()
    | float()
    | boolean()
    | binary()
    | atom()
    | [result_selection_t()]
}
Link to this type result_t() View Source
result_t() ::
  %{data: nil | result_selection_t()}
  | %{data: nil | result_selection_t(), errors: [result_error_t()]}
  | %{errors: [result_error_t()]}
Link to this type run_opts() View Source
run_opts() :: [
  context: %{},
  adapter: Absinthe.Adapter.t(),
  root_value: term(),
  operation_name: String.t(),
  analyze_complexity: boolean(),
  max_complexity: non_neg_integer() | :infinity
]
Link to this type run_result() View Source
run_result() :: {:ok, result_t()} | {:error, String.t()}

Link to this section Functions

Link to this function run!(input, schema, options \\ []) View Source
run!(
  binary() | Absinthe.Language.Source.t() | Absinthe.Language.Document.t(),
  Absinthe.Schema.t(),
  Keyword.t()
) :: result_t() | no_return()

Evaluates a query document against a schema, without options.

Options

See run/3 for the available options.

Link to this function run(document, schema, options \\ []) View Source
run(
  binary() | Absinthe.Language.Source.t() | Absinthe.Language.Document.t(),
  Absinthe.Schema.t(),
  run_opts()
) :: run_result()

Evaluates a query document against a schema, with options.

Options

  • :adapter - The name of the adapter to use. See the Absinthe.Adapter behaviour and the Absinthe.Adapter.Passthrough and Absinthe.Adapter.LanguageConventions modules that implement it. (Absinthe.Adapter.LanguageConventions is the default value for this option.)
  • :operation_name - If more than one operation is present in the provided query document, this must be provided to select which operation to execute.
  • :variables - A map of provided variable values to be used when filling in arguments in the provided query document.
  • :context -> A map of the execution context.
  • :root_value -> A root value to use as the source for toplevel fields.
  • :analyze_complexity -> Whether to analyze the complexity before executing an operation.
  • :max_complexity -> An integer (or :infinity) for the maximum allowed complexity for the operation being executed.

Examples

"""
query GetItemById($id: ID) {
  item(id: $id) {
    name
  }
}
"""
|> Absinthe.run(App.Schema, variables: %{"id" => params[:item_id]})

See the Absinthe module documentation for more examples.