{"record":{"id":"60d9c5b5b182d0d4","repo":"dgraph-io/dgraph","slug":"supplied-operation-name-s-isn-t-present-in-the-re","errorCode":null,"errorMessage":"Supplied operation name %s isn't present in the request.","messagePattern":"Supplied operation name (.+?) isn't present in the request\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/request.go","lineNumber":70,"sourceCode":"\tlistErr := validator.Validate(s.schema, doc, req.Variables)\n\tif len(listErr) != 0 {\n\t\treturn nil, listErr\n\t}\n\n\tif len(doc.Operations) == 1 && doc.Operations[0].Operation == ast.Subscription &&\n\t\ts.schema.Subscription == nil {\n\t\treturn nil, errors.Errorf(\"Not resolving subscription because schema doesn't have any \" +\n\t\t\t\"fields defined for subscription operation.\")\n\t}\n\n\tif len(doc.Operations) > 1 && req.OperationName == \"\" {\n\t\treturn nil, errors.Errorf(\"Operation name must by supplied when query has more \" +\n\t\t\t\"than 1 operation.\")\n\t}\n\n\top := doc.Operations.ForName(req.OperationName)\n\tif op == nil {\n\t\treturn nil, errors.Errorf(\"Supplied operation name %s isn't present in the request.\",\n\t\t\treq.OperationName)\n\t}\n\n\tvars, gqlErr := validator.VariableValues(s.schema, op, req.Variables)\n\tif gqlErr != nil {\n\t\treturn nil, gqlErr\n\t}\n\n\toperation := &operation{op: op,\n\t\tvars:                    vars,\n\t\tquery:                   req.Query,\n\t\theader:                  req.Header,\n\t\tdoc:                     doc,\n\t\tinSchema:                s,\n\t\tinterfaceImplFragFields: map[*ast.Field]string{},\n\t}\n\n\t// recursively expand fragments in operation as selection set fields","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/request.go#L52-L88","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{\"query\": \"query GetUser { user { id } }\", \"operationName\": \"getuser\"}\n// after\n{\"query\": \"query GetUser { user { id } }\", \"operationName\": \"GetUser\"}","handlingStrategy":"validation","validationCode":"// ensure the requested operation name appears in the document\nif !operationPresent(query, operationName) {\n    return fmt.Errorf(\"operation %q not found in document\", operationName)\n}","typeGuard":"func operationPresent(query, opName string) bool {\n    re := regexp.MustCompile(`\\b(query|mutation|subscription)\\s+` + regexp.QuoteMeta(opName) + `\\b`)\n    return re.MatchString(query)\n}","tryCatchPattern":"op, err := sch.Operation(req)\nif err != nil {\n    if strings.Contains(err.Error(), \"isn't present in the request\") {\n        http.Error(w, `unknown operationName`, http.StatusBadRequest)\n        return\n    }\n    return err\n}","preventionTips":["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."],"tags":["graphql","request","operation-name"],"backgroundTag":"operation-not-found","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}