Gaiia.Operation (Gaiia v0.2.0)

Copy Markdown View Source

Build GraphQL operation strings from introspection-style argument specs at runtime.

Operations have shape:

<op_type> <op_name>($a: T!, $b: U) { <op_name>(a: $a, b: $b) { <selection> } }

Only variables that the caller actually supplies are declared and passed, so GraphQL doesn't reject the request for unused variables.

Summary

Types

arg_spec()

@type arg_spec() :: %{required(String.t()) => term()}

op_type()

@type op_type() :: :query | :mutation

Functions

build(op_type, name, args, variables, selection)

@spec build(op_type(), String.t(), [arg_spec()], map(), String.t()) :: String.t()

Build a GraphQL operation string.

  • op_type:query or :mutation
  • name — the operation/field name (e.g. "account")
  • args — list of argument specs [%{"name" => "id", "type" => type_ref}, ...]
  • variables — variables map; only keys present here are declared/passed
  • selection — selection set body (without braces). Empty string means no selection.