ectograph v0.2.0 Ectograph.Definitions

Summary

Functions

Build a field (a.k.a. definition)

Extend the arguments of a field

Extend the fields of the type of a field

Pick specific fields from a type definition. When the second argument is nil, it returns an empty map

Functions

add_association(definition, resolver, association_name, opt \\ :single)

Add an association to a definition.

e.g.

  type_def = build(Quote, :all)
  type_def = add_association(type_def, Author, :author) # default is ':single'
  type_def = add_association(type_def, Author, :authors, :multiple)
build(resolver, method, attributes \\ nil)

Build a field (a.k.a. definition).

extend_arguments(definition, with_map)

Extend the arguments of a field.

Given a field (a.k.a. definition) of the form %{ type: %{ fields: %{} }, args: %{} }, it will merge the args map with the map given as the second argument to this function.

extend_type_fields(definition, with_map)

Extend the fields of the type of a field.

Given a field (a.k.a. definition) or a GraphQL.Type.List, it will merge the type.fields map with the map given as the second argument to this function.

pick_types(type_def, keys)

Pick specific fields from a type definition. When the second argument is nil, it returns an empty map.

  pick_types(
    %{ name: "Whatever", fields: %{ a: %{ type: ... }, b: %{ type: ... } }},
    [:a]
  )
  -> %{ a: %{ type: ... } }