{"record":{"id":"95be97d86c5ce83b","repo":"cayleygraph/cayley","slug":"unsupported-query-type","errorCode":null,"errorMessage":"unsupported query type","messagePattern":"unsupported query type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/graphql/graphql.go","lineNumber":426,"sourceCode":"\t\t} else if len(arr) > 1 {\n\t\t\tv = arr\n\t\t}\n\t\tout[f.Alias] = v\n\t}\n\treturn out, nil\n}\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 {","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/graphql/graphql.go#L408-L444","documentation":"This error is returned by the GraphQL query parser in Parse when the parsed document does not contain exactly one definition. Cayley's GraphQL-ish schema query layer only accepts a document with a single operation definition, so any other count (zero definitions or multiple definitions) is rejected.","triggerScenarios":"Calling Execute/Parse (or issuing an HTTP query) with a GraphQL document whose parsed AST has len(doc.Definitions) != 1 — e.g. an empty query string, a document with only fragments, or a query containing two operations.","commonSituations":"Sending an empty body or whitespace-only query over the /graphql endpoint; programmatically concatenating two GraphQL operations; sending only a named fragment with no operation.","solutions":["Send exactly one GraphQL operation per request","Check that the query string is non-empty and not only whitespace/fragments","Split multiple operations into separate HTTP requests","Validate the document client-side before sending"],"exampleFix":"// before\ndoc := \"query { user } mutation { noop }\"\n// after\ndoc := \"query { user }\"","handlingStrategy":"validation","validationCode":"function hasSingleDefinition(doc) {\n  const defs = doc.definitions || [];\n  return defs.length === 1 && defs[0].kind === 'OperationDefinition';\n}\nif (!hasSingleDefinition(parsed)) throw new Error('query must contain exactly one operation');","typeGuard":"const isSingleQuery = (doc) => doc?.definitions?.length === 1 && doc.definitions[0].kind === 'OperationDefinition';","tryCatchPattern":null,"preventionTips":["Send one operation per request","Never post an empty or fragment-only body","Validate queries with a GraphQL parser client-side first"],"tags":["graphql","query-parsing","validation"],"backgroundTag":"schema-validation-failed","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"}