{"record":{"id":"243f8d49cf417c12","repo":"cayleygraph/cayley","slug":"unsupported-operation-s","errorCode":null,"errorMessage":"unsupported operation: %s","messagePattern":"unsupported operation: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/graphql/graphql.go","lineNumber":432,"sourceCode":"}\n\nfunc Parse(r io.Reader) (*Query, error) {\n\tdata, err := ioutil.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdoc, err := parser.Parse(parser.ParseParams{Source: string(data)})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(doc.Definitions) != 1 {\n\t\treturn nil, fmt.Errorf(\"unsupported query type\")\n\t}\n\tdef, ok := doc.Definitions[0].(*ast.OperationDefinition)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unsupported query type: %T\", doc.Definitions[0])\n\t} else if def.Operation != \"query\" {\n\t\treturn nil, fmt.Errorf(\"unsupported operation: %s\", def.Operation)\n\t}\n\tfields, all, err := setToFields(def.SelectionSet, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t} else if all {\n\t\treturn nil, fmt.Errorf(\"expand all is not supported at top level\")\n\t}\n\treturn &Query{fields: fields}, nil\n}\n\nfunc setToFields(set *ast.SelectionSet, labels []quad.Value) (out []field, all bool, _ error) {\n\tif set == nil {\n\t\treturn\n\t}\n\tfor _, s := range set.Selections {\n\t\tswitch sel := s.(type) {\n\t\tcase *ast.Field:\n\t\t\tfld, err := convField(sel, labels)","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/graphql/graphql.go#L414-L450","documentation":"Returned when the single operation definition exists but its operation type is not \"query\" — i.e. mutation or subscription was used. Cayley's GraphQL query endpoint is read-only and only supports query operations.","triggerScenarios":"Submitting `mutation { ... }` or `subscription { ... }` documents to the GraphQL query parser via Execute, Parse, or the HTTP query endpoint.","commonSituations":"Clients assuming a full GraphQL server (with mutations); auto-generated clients from a schema that declares mutations; testing write operations against Cayley's read-only GraphQL layer.","solutions":["Use `query` operations only; perform writes via Cayley's other write APIs (e.g. the writer/quad endpoints)","Rewrite the operation as a query if read intent was meant","Switch to the gRPC/HTTP write API for data mutations"],"exampleFix":"// before\nq := \"mutation { addPerson }\"\n// after\nq := \"query { person }\"","handlingStrategy":"validation","validationCode":"if (doc.definitions[0]?.operation && doc.definitions[0].operation !== 'query') {\n  throw new Error(`unsupported operation: ${doc.definitions[0].operation}; only 'query' is allowed`);\n}","typeGuard":"const isQueryOp = (def) => def?.kind === 'OperationDefinition' && def.operation === 'query';","tryCatchPattern":null,"preventionTips":["Treat Cayley's GraphQL endpoint as read-only","Perform writes via the dedicated write APIs","Lint queries to reject mutation/subscription operations"],"tags":["graphql","unsupported-operation","validation"],"backgroundTag":"unsupported-operation","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}