{"record":{"id":"83af958fda21764d","repo":"cayleygraph/cayley","slug":"filters-inside-expand-all-are-not-supported","errorCode":null,"errorMessage":"filters inside expand all are not supported","messagePattern":"filters inside expand all are not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/graphql/graphql.go","lineNumber":458,"sourceCode":"\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)\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]","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/graphql/graphql.go#L440-L476","documentation":"The expand-all wildcard field must be a bare selection: it cannot carry directive-style filter arguments (`has`) or nested sub-fields. Any filtering inside an expand-all selection is unsupported and rejected.","triggerScenarios":"Writing `query { node { _(has: \"name\") } }` or `query { node { _ { name } } }` — convField produces a wildcard field with non-empty Has or Fields, and setToFields rejects it.","commonSituations":"Trying to filter which predicates are expanded; nesting fields under `_` assuming it selects sub-properties; translating SQL-ish 'select * where' intuition into GraphQL syntax.","solutions":["Use `_` with no arguments and no sub-selection, then filter results client-side","Filter by labeling the data first and querying labeled predicates explicitly","Expand via explicit predicate names with `has` filters on named fields instead"],"exampleFix":"// before\nq := \"query { node { _(has: \"name\") } }\"\n// after\nq := \"query { node { _ } }\"","handlingStrategy":"validation","validationCode":"function checkWildcardClean(sel) {\n  if (sel.name?.value !== '_') return;\n  if ((sel.arguments?.length ?? 0) > 0 || (sel.selectionSet?.selections?.length ?? 0) > 0) {\n    throw new Error('expand all (_) cannot have arguments or sub-selections');\n  }\n}","typeGuard":"const isCleanWildcard = (s) => s?.name?.value === '_' && !s.arguments?.length && !s.selectionSet;","tryCatchPattern":null,"preventionTips":["Use `_` bare, with no has arguments or nested fields","Filter expanded results client-side","Consult docs on expand-all limitations before use"],"tags":["graphql","expand-all","filters"],"backgroundTag":"unsupported-operation","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}