Skip to content
Latchkey

GraphQL Code Generator "Cannot query field ... on type ..." in CI

GraphQL Code Generator validates every operation against the loaded schema. "Cannot query field X on type Y" means an operation requests a field the schema no longer has (or never had), so validation fails before types are generated.

What this error means

graphql-codegen fails with "Cannot query field \"<field>\" on type \"<Type>\"." pointing at an operation document, often after the API schema changed.

graphql-codegen
Cannot query field "fullName" on type "User". Did you mean "name"?

Common causes

The operation drifted from the schema

The query selects a field that was renamed or removed in the schema, so validation against the current SDL fails.

Codegen loaded a stale or wrong schema

CI loaded an older schema than the operations were written for, making valid fields look unknown.

How to fix it

Align the operation with the schema

  1. Read the suggested field in "Did you mean ...".
  2. Update the operation to select fields the schema actually defines.
  3. Re-run codegen to confirm validation passes.
queries/user.graphql
query User {
  user(id: $id) {
    name
  }
}

Load the current schema in CI

Make sure codegen reads the same schema version the operations target, for example by introspecting the deployed API or committing the up-to-date SDL.

codegen.yml
# codegen.yml
schema: ${SCHEMA_URL:./schema.graphql}

How to prevent it

  • Generate operations and schema from the same source of truth.
  • Run codegen in CI on schema changes so drift fails fast.
  • Commit an up-to-date schema or introspect the live endpoint.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →