Queries

Queries are a core concept in GraphQL, responsible for all Read operations. Currently, all queries are capped at 1k entries.

Querying Single Entries

Single entry queries can take three inputs:

  • where: WhereUniqueInput! A required object type specifying a field with a unique constraint (like id)
  • stage: Stage! = DRAFT A required enumeration indicating the current content Stage (defaults to DRAFT)
  • locales: [Locale!]! = [en] A required array of one or more locales, defaults to the project's default.

Standard Query

{
product(where: { id: "123xyz" }) {
name
}
}

Standard Query with Locale

{
product(where: { id: "123xyz" }, locales: [en, fr, de]) {
name
}
}

Standard Query with Stage

{
product(where: { id: "123xyz" }, stage: PUBLISHED) {
name
}
}

Querying Multiple Entries

Multiple/Plural entry queries can take nine inputs:

  • where: WhereInput An optional object type to filter the content based on a nested set of criteria.
  • orderBy: ProductOrderByInput An enumeration type to select which field and direction to order the content on.
  • skip: Int An optional integer to offset the response.
  • after: String An optional ID string, replicating similar behavior as a pointer.
  • before: String An optional ID string, replicating similar behavior as a pointer.
  • first: Int An optional integer to slice the first n entries.
  • last: Int An optional integer to slice the last n entries.
  • stage: Stage! = DRAFT A required enumeration indicating the current content Stage (defaults to DRAFT)
  • locales: [Locale!]! = [en] A required array of one or more locales, defaults to the project's default.

Standard Query

{
products {
name
}
}

Standard Query with Where

{
product(where: { _search: "ACME" }) {
name
}
}

Standard Query with OrderBy

{
products(orderBy: createdAt_DESC) {
name
}
}

Standard Query with Skip

{
products(skip: 3) {
name
}
}

Standard Query with After

#prettier-ignore
{
products(after: "123xyz") {
name
}
}

Standard Query with Before

{
products(before: "123xyz") {
name
}
}

Standard Query with First

{
products(first: 3) {
name
}
}

Standard Query with Last

{
products(last: 3) {
name
}
}

Standard Query with Stage

{
products(stage: PUBLISHED) {
name
}
}

Standard Query with Locales

{
products(locales: [en, fr, de]) {
name
}
}

Were you expecting something more?

We are constantly contributing to our documentation, but if you spot something we're missing, let us know and we'll be sure to add it.

This site uses cookies to provide you with a better user experience. For more information, refer to our Privacy Policy