{"record":{"id":"cb6707f57d6996b0","repo":"cayleygraph/cayley","slug":"unknown-selection-type-t","errorCode":null,"errorMessage":"unknown selection type: %T","messagePattern":"unknown selection type: %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/graphql/graphql.go","lineNumber":464,"sourceCode":"\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)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, false, err\n\t\t\t}\n\t\t\tif fld.Via == quad.IRI(AnyKey) {\n\t\t\t\tif len(set.Selections) != 1 {\n\t\t\t\t\treturn nil, false, fmt.Errorf(\"expand all cannot be used with other fields\")\n\t\t\t\t} else if len(fld.Has) != 0 || len(fld.Fields) != 0 {\n\t\t\t\t\treturn nil, false, fmt.Errorf(\"filters inside expand all are not supported\")\n\t\t\t\t}\n\t\t\t\treturn nil, true, nil\n\t\t\t}\n\t\t\tout = append(out, fld)\n\t\tdefault:\n\t\t\treturn nil, false, fmt.Errorf(\"unknown selection type: %T\", s)\n\t\t}\n\t}\n\treturn\n}\n\nfunc stringToVia(s string) (_ quad.IRI, rev bool) {\n\tif len(s) > 0 && s[0] == '~' {\n\t\trev = true\n\t\ts = s[1:]\n\t}\n\tif len(s) > 2 && s[0] == '<' && s[len(s)-1] == '>' {\n\t\ts = s[1 : len(s)-1]\n\t}\n\treturn quad.IRI(s), rev\n}\n\nfunc argsToHas(dst []has, args []*ast.Argument, rev bool, labels []quad.Value) (out []has, err error) {\n\tout = dst","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/graphql/graphql.go#L446-L482","documentation":"setToFields switches over the ast.Selection types it understands (fields, fragments) and any other selection type falls into a default case that errors, naming the concrete Go type encountered. This indicates a selection kind the parser does not implement.","triggerScenarios":"A parsed document whose SelectionSet contains a selection type other than *ast.Field or *ast.InlineFragment handling in the switch — e.g. unusual AST shapes produced by certain parser versions or hand-crafted ASTs passed to Parse.","commonSituations":"Version drift where the gqlparser emits a new selection type; constructing ast.Selection values manually in tests; document features (rare constructs) unsupported by the converter.","solutions":["Upgrade/downgrade Cayley so its parser and converter versions match","Check which type appears in the message and avoid that GraphQL construct","Use standard field and inline-fragment selections only"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Validate only standard field/fragment selections are used\nfunction usesOnlySupportedSelections(sel) {\n  return (sel || []).every(s => ['Field','InlineFragment'].includes(s.kind));\n}","typeGuard":"const isSupportedSelection = (s) => s && (s.kind === 'Field' || s.kind === 'InlineFragment');","tryCatchPattern":"try {\n  result, err := engine.Parse(ctx, q)\n  if err != nil {\n    if strings.HasPrefix(err.Error(), \"unknown selection type\") {\n      log.Printf(\"unsupported GraphQL construct: %v\", err)\n      // degrade or upgrade library\n    }\n    return err\n  }\n}","preventionTips":["Keep the library and its gqlparser dependency versions in sync","Avoid exotic GraphQL constructs","Pin dependency versions in go.mod"],"tags":["graphql","internal","type-mismatch"],"backgroundTag":"unexpected-api-response-shape","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"}