githubEdit

circle-rightRelay Connections

Migration guide for the breaking change from simple list fields to Relay-style Connection objects

Audience: Programmer

Overview

This guide covers a breaking change in the pyck GraphQL API where all entity relationship fields now return Relay-style Connection objects instead of simple lists. This change enables consistent cursor-based pagination, filtering, and ordering across all relationships.

What Changed

Before: Relationship fields returned simple arrays.

type Group {
  users: [User!]
  roles: [Role!]
}

After: Relationship fields return Connection objects with edges and nodes.

type Group {
  users(
    after: Cursor
    first: Int
    before: Cursor
    last: Int
    orderBy: UserOrder
    where: UserWhereInput
  ): UserConnection!
  roles(
    after: Cursor
    first: Int
    before: Cursor
    last: Int
    orderBy: RoleOrder
    where: RoleWhereInput
  ): RoleConnection!
}

Affected Relationship Fields

The following relationship fields have been changed to return Connection objects:

Inventory Service

Type
Field
Connection Type

InventoryItemSet

items

InventoryItemConnection

ReplenishmentOrder

replenishmentOrderItems

ReplenishmentOrderItemConnection

Repository

itemMovementToRepositories

ItemMovementConnection

Repository

itemMovementFromRepositories

ItemMovementConnection

Repository

repositoryMovementToRepositories

RepositoryMovementConnection

Repository

repositoryMovementFromRepositories

RepositoryMovementConnection

Repository

repositoryMovementRepositories

RepositoryMovementConnection

Repository

repositoryTransactions

TransactionConnection

Repository

repositoryStocks

StockConnection

Repository

children

RepositoryConnection

Management Service

Type
Field
Connection Type

Device

deviceLocationsDevice

DeviceLocationConnection

Device

deviceUsersDevice

DeviceUserConnection

Group

users

UserConnection

Group

roles

RoleConnection

Location

deviceLocationsLocation

DeviceLocationConnection

Role

users

UserConnection

Role

groups

GroupConnection

Role

policies

AccessPolicyConnection

Tenant

tenantUsers

UserConnection

User

roles

RoleConnection

User

groups

GroupConnection

User

deviceUsersUsers

DeviceUserConnection

Receiving Service

Type
Field
Connection Type

ReceivingInbound

inboundItems

ReceivingInboundItemConnection

Workflow Service

Type
Field
Connection Type

Workflow

workflowSignals

WorkflowSignalConnection

Connection Object Structure

All Connection types follow the Relay specification with this structure:

Migration Steps

Step 1: Update Query Structure

Change your queries to use the edges { node { ... } } pattern.

Before:

After:

Step 2: Update Response Handling

Update your client code to handle the new response structure.

Before (JavaScript):

After (JavaScript):

Step 3: Implement Pagination (Optional)

Take advantage of the new pagination capabilities.

Pagination helper (JavaScript):

Step 4: Add Filtering and Ordering (Optional)

Use the new filtering and ordering capabilities on relationship fields.

Complete Migration Examples

Example 1: InventoryItemSet with Items

Before:

After:

Example 2: ReceivingInbound with InboundItems

Before:

After:

Example 3: Workflow with Signals

Before:

After:

Example 4: Role with Users, Groups, and Policies

Before:

After:

Benefits of This Change

  1. Consistent Pagination: All relationship fields now support cursor-based pagination with first, last, before, and after arguments.

  2. Filtering on Relationships: Apply WhereInput filters directly on relationship fields to reduce data transfer.

  3. Ordering on Relationships: Order related items using OrderBy inputs on the relationship itself.

  4. Total Count: Always know how many related items exist with the totalCount field.

  5. Relay Compliance: Full compliance with the Relay Cursor Connections Specificationarrow-up-right.

Troubleshooting

Error: Cannot query field "edges" on type "[User!]"

This error indicates you are using the old query structure. Update your query to use the Connection pattern:

Error: Cannot query field "totalCount"

Ensure you are querying totalCount at the Connection level, not inside edges or node:

Performance Considerations

When fetching nested relationships, always use the first argument to limit results:

Last updated

Was this helpful?