View Source Absinthe.Relay.Connection.Notation (absinthe_relay v1.5.2)

Macros used to define Connection-related schema entities

See Absinthe.Relay.Connection for more information.

If you wish to use this module on its own without use Absinthe.Relay you need to include

@pipeline_modifier Absinthe.Relay.Schema

in your root schema module.

Link to this section Summary

Link to this section Functions

Link to this function

additional_types(arg1, _)

View Source
Link to this macro

connection(attrs)

View Source (macro)
Link to this macro

connection(attrs, attrs)

View Source (macro)

Define a connection type for a given node type.

examples

Examples

A basic connection for a node type, :pet. This well generate simple :pet_connection and :pet_edge types for you:

connection node_type: :pet

You can provide a custom name for the connection type (just don't include the word "connection"). You must still provide the :node_type. You can create as many different connections to a node type as you want.

This example will create a connection type, :favorite_pets_connection, and an edge type, :favorite_pets_edge:

connection :favorite_pets, node_type: :pet

You can customize the connection object just like any other object:

connection :favorite_pets, node_type: :pet do
  field :total_age, :float do
    resolve fn
      _, %{source: conn} ->
        sum = conn.edges
        |> Enum.map(fn edge -> edge.node.age)
        |> Enum.sum
        {:ok, sum}
    end
  end
  edge do
    # ...
  end
end

Just remember that if you use the block form of connection, you must call the edge macro within the block to make sure the edge type is generated. See the edge macro below for more information.

Link to this macro

connection(identifier, attrs, list)

View Source (macro)
Link to this macro

edge(attrs, list)

View Source (macro)

Customize the edge type.

examples

Examples

connection node_type: :pet do
  # ...
  edge do
    field :node_name_backwards, :string do
      resolve fn
        _, %{source: edge} ->
          {:ok, edge.node.name |> String.reverse}
      end
    end
  end
end