View Source Absinthe.Relay.Connection.Notation (absinthe_relay v1.6.0)
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.Schemain your root schema module.
Summary
Functions
Define a connection type for a given node type.
Examples
A basic connection for a node type, :pet. This well generate simple
:pet_connection and :pet_edge types for you:
connection node_type: :petYou 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: :petYou 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
endJust 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.
Customize the edge type.
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