Repository navigation
fix(graphql): use placeholders when grouping on leaf-backed object fields - #1454
Closed
myronmarston wants to merge 1 commit into
Closed
myronmarston wants to merge 1 commit into
myronmarston wants to merge 1 commit into
Conversation
myronmarston
force-pushed
the
myron/gh-1453-followups
branch
3 times, most recently
from
November 10, 2026 02:54
cd0516b to
622f0e5
Compare
myronmarston
changed the base branch from
main
to
myron/assert-missing-aggregations
November 10, 2026 03:07
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
myronmarston
force-pushed
the
myron/assert-missing-aggregations
branch
from
November 11, 2026 01:26
4213d33 to
713d132
Compare
myronmarston
force-pushed
the
myron/gh-1453-followups
branch
from
November 11, 2026 01:26
622f0e5 to
22ad8f6
Compare
…elds Follow-up to #1453. A sub-aggregation grouping on an object field backed by a leaf index field, such as an Apollo entity ref, used a separate `missing` aggregation instead of a missing value placeholder. Each `missing` aggregation doubles the number of aggregations below it. - Record the `type_name` of each leaf `IndexField` in runtime metadata. - Record `grouping_missing_value_placeholder` on enum runtime metadata, like scalars already do. Every enum is now dumped, so the GraphQL layer can look up the placeholder of any enum. - Keep the runtime metadata of every scalar and enum type that an index field references, even when the GraphQL schema omits the type because only `indexing_only` fields use it. - `Schema#grouping_missing_value_placeholder_for` reads placeholders from runtime metadata. `Type` uses it for its own placeholder and for the new `grouping_missing_value_placeholders_by_index_leaf_path`, which the query adapter uses instead of scanning index definitions. Generated with Claude Code
myronmarston
force-pushed
the
myron/gh-1453-followups
branch
from
November 11, 2026 02:02
22ad8f6 to
7ea13ff
Compare
myronmarston
added a commit
that referenced
this pull request
Nov 12, 2026
… 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 sub-aggregation nests one level per grouping field. A grouping without a missing value placeholder needs a separate
missingaggregation at every level, so the number of aggregations grows exponentially and can exceed the max clause count (#882). #890, #893, #894 and #895 added placeholders totermsaggregations, but leaf-backed object fields had none.Stacked on #1456, which adds the assertions on
missingaggregations that this PR updates.How. The placeholder stays an attribute of the type. Each leaf index field records its type name, and the GraphQL layer looks up that type's placeholder in runtime metadata.
IndexFieldrecordstype_name.grouping_missing_value_placeholder, as scalar runtime metadata does. Every enum is now dumped, including enums with no value-level metadata.indexing_onlyfields use them.Schema#grouping_missing_value_placeholder_forreads placeholders from runtime metadata.Typeuses it, and the query adapter uses the newType#grouping_missing_value_placeholders_by_index_leaf_path.Verification. The entity ref assertion from #1456 changes from a
missingaggregation onsponsor_idto none. TheBooleanand enum assertions stay the same. Without the enum placeholder, the enum assertion fails.🤖 Generated with Claude Code