Search⌘ K

Relay Connection

Explore how to implement Relay connections in GraphQL APIs built with Elixir and Absinthe. Understand the use of connection and edge types to enable pagination. Learn to adapt your schema and resolver logic to handle Relay-compliant paginated queries smoothly and integrate with front-end frameworks like Relay.

Supporting Relay connections

To support pagination, Relay has defined a set of conventions that models lists of records and related metadata. As an example, let’s review the :menu_items field in the PlateSlate schema. In its current, simplistic state, it looks something like this:

In short, the RootQueryType has a field, menuItems, that returns a list of MenuItem records. If we model the field as a Relay connection, it will change and look something like this:

This necessitates the addition of two new object types:

  • MenuItemConnection: An object type that contains the edges and the pageInfo fields.
  • MenuItemEdge: An object type that models
...