published fresh until

Cannot query field: how do I fix GraphQL validation?

Summary As of October 2026, validate the failing GraphQL operation against the schema served by the same API: correct the field or argument, use a fragment for concrete-type fields, and refresh generated operations only after the schema matches (checked 2026-10-28).

Not for resolver execution failures after a valid query, such as a resolver returning null for a Non-Null field.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Cannot query field "foo" on type "Query".

The GraphQL operation names a field absent from its parent type in the schema used for validation.

First action — call validate(schema, parse(operation)) from graphql against the schema corresponding to the failing API, before changing resolvers or regenerating client code.

Evidence status — official validation rules establish the messages and schema constraints; issue reports show union and introspection cases, but this procedure has not been executed against your API (checked 2026-10-28).

Not for: resolver execution failures after a valid query, such as a resolver returning null for a Non-Null field; see the official field-error explanation.

What changed

  • These messages establish an operation/schema mismatch, not necessarily a recent package regression. The official validation guide explains checking operations before execution (checked 2026-10-28).
  • The related message is Unknown argument "foo" on field "Query.hello". The GraphQL.js field rule and argument rule construct these messages on the 16.x.x source branch (checked 2026-10-28); names are substitutions and a suggestion may follow. This is not a recommendation to install that branch.

How to fix

1. Keep the complete operation, variables, error location and API address together. Obtain that API's schema through an approved schema artifact or permitted introspection using the same access context. Compare the schema used by the client with the one deployed at the failing API; a schema from another environment cannot establish validity here. 2. Inspect the parent type named in the error. For a missing field, copy the actual field name and case from that type. An alias changes the response key, not which schema field exists. If the field belongs only to a concrete member of an interface or union, use an inline fragment on that real type. The official validation guide above shows why abstract-type selections need fragments. 3. For an unknown argument, inspect the arguments on that exact parent-type/field pair. Copy the declared name; moving data into variables does not make an undeclared argument valid. Do not confuse field arguments with members of an input object. The argument-name specification requires arguments to be defined on the target field or directive. 4. Validate the edited document before executing it. The official rule examples import buildSchema, parse and validate from graphql. For an SDL artifact, the following adaptation is an Untested experiment; substitute your actual SDL and operation text:

import {buildSchema, parse, validate} from 'graphql';
const schema = buildSchema(schemaSDL);
const errors = validate(schema, parse(operationText));
console.log(errors.map(error => error.message));

Use the full default rules; this example does not check runtime variable values, authorization or resolver behavior. Do not disable validation to make a query execute. 5. If the schema is wrong, correct and deploy the intended schema through the normal API change process, then validate again. If only a client artifact is stale, refresh it with the project's existing generator after selecting the correct schema. There is no universal GraphQL code-generation command. Recheck persisted operations as well as source query files.

Diagnostic: Cannot query field "foo" on type "Query".

The linked rules construct these message patterns with substituted names; the literal foo/Query/hello examples are illustrative and are not reproduced verbatim in those sources. foo, Query and hello are illustrative substitutions, not prescribed API names. A field lookup failure happens before resolving that invalid field; adding a resolver without exposing a matching schema field is insufficient.

What to test

Validate the original operation and its fragments against the target schema. Then run an authorized read-only operation with representative variables and inspect GraphQL errors as well as returned data. Check generated and persisted operation artifacts separately. These application checks are an Untested experiment; do not execute a mutation merely to validate its document.

Community evidence

  • vslinko's GraphQL.js issue 22 reports a field query directly on a union. It illustrates why a field present on a member is not automatically selectable on the union itself.
  • Betree's GraphQL.js issue 2895 reports an unknown introspection argument; another participant independently confirms the symptom, and maintainer IvanGoncharov asks for the backend implementation version. This is a historical compatibility case, not evidence that every unknown argument is a typo or that a current upgrade is required.

Pitfalls

Do not rename schema fields to match an agent's invented query. Do not retry the same invalid document or clear a response cache as the first remedy. A suggestion in an error is a spelling hint, not proof that the suggested field expresses the intended business operation. If introspection is restricted, ask for an approved schema artifact rather than weakening API policy.

A prompt to give your agent

Your training data may predate this API schema. Read the linked official validation guide and GraphQL.js rules; do not invent field or argument names. Identify the failing API, schema artifact, parent type and exact operation. Validate first, then propose one schema-grounded query correction or identify an API/schema deployment mismatch. Keep mutations unexecuted and report client generation separately.

Limits

No API operation, schema refresh or code generation was executed. The issue evidence covers historical union and introspection failures, not current prevalence or a universal repair. Federation composition, authorization-dependent schema visibility and vendor-specific error envelopes are outside this procedure. Checked 2026-10-28.

Started from a post by @Betree, packaged by the editor. Original post

Subjects

More in graphql

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Cannot query field: how do I fix GraphQL validation?
Summary: As of October 2026, validate the failing GraphQL operation against the schema served by the same API: correct the field or argument, use a fragment for concrete-type fields, and refresh generated operations only after the schema matches (checked 2026-10-28).
Copy for agent
get the whatworks thread graphql-cannot-query-field-unknown-argument-schema-validation and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread graphql-cannot-query-field-unknown-argument-schema-validation
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp