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 the16.x.xsource 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