dgraph-io/dgraph · error
Supplied operation name %s isn't present in the request.
Error message
Supplied operation name %s isn't present in the request.
What it means
The request supplied an OperationName, but no operation with that name exists in the parsed document (doc.Operations.ForName returned nil). This catches typos and mismatches between the query text and the declared operation name.
Source
Thrown at graphql/schema/request.go:70
listErr := validator.Validate(s.schema, doc, req.Variables)
if len(listErr) != 0 {
return nil, listErr
}
if len(doc.Operations) == 1 && doc.Operations[0].Operation == ast.Subscription &&
s.schema.Subscription == nil {
return nil, errors.Errorf("Not resolving subscription because schema doesn't have any " +
"fields defined for subscription operation.")
}
if len(doc.Operations) > 1 && req.OperationName == "" {
return nil, errors.Errorf("Operation name must by supplied when query has more " +
"than 1 operation.")
}
op := doc.Operations.ForName(req.OperationName)
if op == nil {
return nil, errors.Errorf("Supplied operation name %s isn't present in the request.",
req.OperationName)
}
vars, gqlErr := validator.VariableValues(s.schema, op, req.Variables)
if gqlErr != nil {
return nil, gqlErr
}
operation := &operation{op: op,
vars: vars,
query: req.Query,
header: req.Header,
doc: doc,
inSchema: s,
interfaceImplFragFields: map[*ast.Field]string{},
}
// recursively expand fragments in operation as selection set fieldsView on GitHub (pinned to 759e242be6)
Solutions
- Make req.OperationName exactly match one of the named operations in the query (GraphQL names are case-sensitive).
- Remove operationName if the document has a single anonymous operation.
- List operations in the document and correct the client's configured name.
Example fix
// before
{"query": "query GetUser { user { id } }", "operationName": "getuser"}
// after
{"query": "query GetUser { user { id } }", "operationName": "GetUser"} Defensive patterns
Strategy: validation
Validate before calling
// ensure the requested operation name appears in the document
if !operationPresent(query, operationName) {
return fmt.Errorf("operation %q not found in document", operationName)
} Type guard
func operationPresent(query, opName string) bool {
re := regexp.MustCompile(`\b(query|mutation|subscription)\s+` + regexp.QuoteMeta(opName) + `\b`)
return re.MatchString(query)
} Try / catch
op, err := sch.Operation(req)
if err != nil {
if strings.Contains(err.Error(), "isn't present in the request") {
http.Error(w, `unknown operationName`, http.StatusBadRequest)
return
}
return err
} Prevention
- Keep operationName and the query document sourced from the same generated artifact.
- Match names case-sensitively (GraphQL names are case-sensitive).
- Do not send operationName for anonymous operations.
- After editing a query, update any persisted operation name references.
When it happens
Trigger: Calling s.Operation(req) with req.OperationName set to a name not matching any named operation in req.Query — including when the query only contains an anonymous operation but an OperationName was supplied.
Common situations: Typo in operationName; client config points to an old operation name after the query was edited; sending operationName with an anonymous (`query { ... }`) document; copied query from another tool.
Related errors
- Operation name must by supplied when query has more than 1 o
- no query string supplied in request
- Cycle detected: %s
- Missing fragment: %s
- PersistedQueryNotFound
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/60d9c5b5b182d0d4.
Report an issue: GitHub.