gatsbyjs/gatsby · error

Deprecated syntax of sort and/or aggregation field arguments

Error message

Deprecated syntax of sort and/or aggregation field arguments were found in your query (see https://gatsby.dev/graphql-nested-sort-and-aggregate). Query was automatically converted to a new syntax. You should update query in your code.\n\nFile: ${filePath}\n\nCurrent query:\n\n${originalQueryText}\n\nConverted query:\n\n${print(transformedDocument)}

What it means

During extractOperations, query validation fails but the document auto-transformer rewrites deprecated sort/aggregate field argument syntax to the new GraphQL spec form and revalidation passes. Gatsby proceeds with the converted query while warning you to update the source, printing the file, original and converted query text.

Source

Thrown at packages/gatsby/src/query/query-compiler.js:225

    doc: originalDoc,
    isHook,
    isStaticQuery,
    isConfigQuery,
  } of parsedQueries) {
    let doc = originalDoc

    let errors = validate(schema, doc, preValidationRules)
    if (errors && errors.length) {
      const originalQueryText = print(originalDoc)
      const { ast: transformedDocument, hasChanged } = tranformDocument(doc)
      if (hasChanged) {
        const newErrors = validate(
          schema,
          transformedDocument,
          preValidationRules
        )
        if (newErrors.length === 0) {
          report.warn(
            `Deprecated syntax of sort and/or aggregation field arguments were found in your query (see https://gatsby.dev/graphql-nested-sort-and-aggregate). Query was automatically converted to a new syntax. You should update query in your code.\n\nFile: ${filePath}\n\nCurrent query:\n\n${originalQueryText}\n\nConverted query:\n\n${print(
              transformedDocument
            )}`
          )
          doc = transformedDocument
          errors = newErrors
        }
      }
    }

    if (errors && errors.length) {
      addError(
        ...errors.map(error => {
          const location = {
            start: locInGraphQlToLocInFile(templateLoc, error.locations[0]),
          }
          return errorParser({
            message: error.message,

View on GitHub (pinned to e85d62f177)

Solutions

  1. Rewrite the query in the file to match the `Converted query` output (nested sort/aggregate syntax, see gatsby.dev/graphql-nested-sort-and-aggregate)
  2. Re-run the build to confirm the warning disappears
  3. Update shared query snippets/templates to the new syntax
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/gatsby/src/query/query-compiler.js:225 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26). Data as JSON: /api/errors/67d49630b21d9e21. Report an issue: GitHub.