Gaiia.TypeRef (Gaiia v0.2.0)

Copy Markdown View Source

Helpers for working with GraphQL type-reference maps as returned by introspection (__Type).

A type reference is a recursive map of the shape:

%{"kind" => "NON_NULL" | "LIST" | "SCALAR" | ..., "name" => name, "ofType" => inner_or_nil}

This module renders such structures to GraphQL syntax (Int!, [String!]!, etc.) and unwraps modifiers to find the underlying named type.

Summary

Functions

Unwrap NON_NULL/LIST modifiers to return the innermost named type ref.

Strip an introspection type reference to the keys this library reads.

Render a type-reference map as a GraphQL type string.

Types

t()

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

Functions

named_type(type)

@spec named_type(t()) :: t()

Unwrap NON_NULL/LIST modifiers to return the innermost named type ref.

prune(type)

@spec prune(t() | nil) :: t() | nil

Strip an introspection type reference to the keys this library reads.

Introspection responses carry descriptions and __typename on every nesting level; the bundled schema dumps keep only kind, name, and ofType so the compile-time literals stay small.

render(map)

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

Render a type-reference map as a GraphQL type string.