Querying data

Our GraphQL API adheres to the Relay specification for connections, providing a robust and standardized way to retrieve your content.

For each content content type you create, we automatically generate corresponding GraphQL query capabilities. This allows you to fetch both single entries and multiple entries, leveraging the power of GraphQL.

Content Type Driven Queries:

The structure of your GraphQL queries directly reflects your defined content types and fields. Field names are converted to a "sluggified" format (camel case) for consistency.

Single Entry Queries:

For each of your content types, we will generate a GraphQL Type. Let's consider a Post content type with a title field, the generated GraphQL Type would look something like this:

type Post {
    title: String
}

To fetch a single Post entry, use the following query. Note that this will return the first matching entry:

query {
    post {
        node {
            title
        }
    }
}

If no matching entry is found, the node will return null.

Connection Queries (Multiple Entries):

Every content type also generates a connection query, enabling you to retrieve multiple entries with pagination, filtering, and sorting. This follows the Relay connection pattern.

Using our Post content type example, you can query all Post entries like this:

query {
    allPost(first: 10) {
        edges {
            node {
                title
            }
        }
    }
}

Notes:

  • Pagination: Connection queries support pagination using the first and last parameters. At least one of these parameters is required when querying a connection.
  • Content Type Based Generation: The query fields (post, allPost) are automatically generated based on your defined content types.
  • Camel Case Sluggified Field Names: Field names from your content types are automatically converted to camel case for GraphQL compatibility.
  • Relay Specification: Our GraphQL endpoint follows the Relay specification for connections, ensuring a consistent and predictable API.
  • Filtering and Sorting: Connection queries support robust filtering and sorting options, allowing you to retrieve specific subsets of your content based on your criteria.
  • Dynamic Queries: The GraphQL API will dynamically reflect changes to your content types, ensuring your queries stay up-to-date with your content structure.