Skip to content

Connections

GraphGlue uses connections both for queries generated using the name parameter of the @DomainNode annotation and NodeSetProperty GraphGlue relationship properties.

The generated connections adhere mostly to the GraphQL Cursor Connections Specification, except:

WARNING

In contrast to the specification, providing both first and last is not supported.

Schema

The generated connections have the following schema:

graphql
type Query {
    types(
        after: String,
        before: String,
        filter: TypeFilterInput,
        first: Int,
        last: Int,
        orderBy: [TypeOrder]
    ): TypeConnection
}

type TypeConnection {
    edges: [TypeEdge!]!
    nodes: [Type!]!
    pageInfo: PageInfo!
    totalCount: Int!
}

type TypeEdge {
    cursor: String!
    node: Type!
}

type PageInfo {
    endCursor: String
    hasNextPage: Boolean!
    hasPreviousPage: Boolean!
    startCursor: String
}

type Type implements Node {
    # ...
}

input TypeFilterInput {
    and: [TypeFilterInput!]
    or: [TypeFilterInput!]
    not: TypeFilterInput
    # ...
}

input TypeOrder {
    direction: OrderDirection = ASC
    field: TypeOrderField = ID
}

enum TypeOrderField {
    ID
    # ...
}

enum OrderDirection {
    ASC
    DESC
}

Inputs

  • after: cursor, only nodes after the cursor are returned.
  • before: cursor, only nodes before the cursor are returned.
  • filter: filters the returned nodes, for filter generation see Filtering.
  • first: only the first n nodes are returned, must not be present if last is present.
  • last: only the last n nodes are returned, must not be present if first is present.
  • orderBy: allows specifying the order of the returned nodes (including the direction). Defaults to order ascending by ID. If a field other than id is specified, the id is used to guarantee strict total order, as the field may not be unique. For order field generation, see Ordering.

INFO

If GraphQL permission checking has been set up, connections are automatically filtered to only include nodes where the specified Permission is granted. This is done before first or last is applied, meaning it is not possible to extract information this way.

Outputs

  • edges: all nodes, with their specific cursor
  • nodes: all nodes
  • totalCount: total count of nodes after filtering, but before pagination
  • pageInfo: allows checking if there are nodes after/before, and getting the cursor for the first/last node returned

WARNING

Cursors are ordering dependent and are meant to be used for pagination, they are not meant to be stored long-term.

INFO

totalCount is only fetched if specified, as it is rather expensive to fetch.

Released under the Apache 2.0 License.