You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 50277f4
Browse filesBrowse the repository at this point in the historyBrowse files
perf(graphql): make sub-aggregations that group on leaf-backed object fields more efficient (#1461)
**Why.** Make sub-aggregation queries that group on leaf-backed object
fields (such as the Apollo entity refs from #1453) as efficient as other
scalar groupings. A grouping without a missing value placeholder needs a
separate `missing` aggregation at every level of a sub-aggregation, so
the number of aggregations grows exponentially and can exceed the max
clause count (#882).
This is an alternative to #1454, which fixes the same bug by recording a
type name on every leaf index field (about 640 lines per
`runtime_metadata.yaml`). This PR records the type name only on the
grouped-by fields of object-typed fields backed by a leaf index field: 6
lines in `artifacts_with_apollo` and 1 in `artifacts`. Stacked on #1456,
which adds the assertions on `missing` aggregations that this PR
updates.
**How.** The schema definition records the type of the backing leaf
index field. The GraphQL layer looks up that type and uses its existing
missing value placeholder, so placeholder resolution
(`$SECURE_RANDOM_VALUE`, enums) stays in `Schema::Type`.
- `GraphQLField` runtime metadata gets an optional
`object_grouping_leaf_type_name`.
- `Field#define_grouped_by_field` sets it when the original field has an
object type and the grouped-by field's `name_in_index` resolves, from
the original field's parent type, to a leaf index field.
- The path lookup from `backing_indexing_field` moves to
`HasIndices#indexing_field_at`, so the grouped-by code can resolve the
grouped-by field's `name_in_index` from the original field's parent
type. `f.backing_indexing_field` can't be used: it resolves from the
derived `GroupedBy` type, which has no indexing fields.
- `Schema::Field#object_grouping_leaf_type` looks up the type (nil when
unset), and the query adapter uses that type's placeholder for the
grouping on a leaf-backed field.
**Verification.** The Apollo entity ref test from #1456 no longer uses a
`missing` aggregation. The leaf-backed query adapter tests, including a
new `Boolean` case with no placeholder, fail without the fix.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
0 commit comments