Fix derived type generation to use directly_queryable? instead of root_document_type? - #1096
Merged
myronmarston merged 2 commits intoMar 30, 2026
Conversation
…t_document_type? Prevents derived types (Connection, Edge, Aggregation, Highlights, GroupedBy, AggregatedValues, SortOrderInput) from being generated for types that only inherit an index. Also renames EnumsForRootDocumentTypes to EnumsForDirectlyQueryableTypes and adds test coverage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
marcdaniels-toast
requested review from
BrianSigafoos-SQ,
ayousufi,
bsorbo,
jwils,
jwondrusch and
myronmarston
as code owners
March 27, 2026 21:34
myronmarston
requested changes
Mar 28, 2026
myronmarston
left a comment
Collaborator
There was a problem hiding this comment.
Great explanation of the issue! I'm in favor of this for the derived types that only apply to directly queryable types. But I'm less onboard for the derived types that usually apply in all cases.
These types are now generated for all types (not just directly queryable ones) since they may be used when the type is embedded in another type. The GraphQL gem automatically prunes unreferenced types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
myronmarston
approved these changes
Mar 30, 2026
myronmarston
added a commit
that referenced
this pull request
Mar 30, 2026
This allows us to define the list of root derived types once, and then expect different things of all elements in the list.
marcdaniels-toast
deleted the
mdaniels/fix-derived-type-generation-semantic
branch
March 30, 2026 21:20
myronmarston
added a commit
that referenced
this pull request
Mar 30, 2026
This allows us to define the list of root derived types once, and then expect different things of all elements in the list.
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.
Consider the following example schema:
graph TD DC[["DistributionChannel<br/>interface<br/>💾 own index<br/>directly queryable"]] R[["Retail<br/>interface<br/>⬆️ inherited index<br/>directly queryable"]] OS["OnlineStore<br/>concrete<br/>⬆️ inherited index<br/>NOT directly queryable"] PS[["PhysicalStore<br/>concrete<br/>💾 own index<br/>directly queryable"]] MS["MobileStore<br/>concrete<br/>⬆️ inherited index<br/>NOT directly queryable"] DC -->|implements| R R -->|implements| OS R -->|implements| PS R -->|implements| MSLegend:
t.index "..."And our semantic definition of
root_document_type?anddirectly_queryable?are:root_document_type?: Returns true if a type is stored in an index (own or inherited)directly_queryable?: Returns true if a type has query fields on the rootQuerytypeBefore indexes could be inherited, these were equivalent. With inheritance, concrete types like
OnlineStorecaninherit an index from
DistributionChannelwithout being directly queryable.When I introduced
directly_queryable?in #1067, I didn't think much about the derived types (Connection, Edge, Aggregation, Highlights, GroupedBy, AggregatedValues, SortOrderInput). But working on the full end-to-end of inherited indexes I had to update hidden_types_spec.rb and this drew my attention to these types.OnlineStoreandMobileStoreinherit an index fromDistributionChannel, makingroot_document_type? == truefor them. But they have no query fields—they're only accessible throughretailersordistribution_channel.Before this fix, derived types (Connection, Edge, Aggregation, Highlights, GroupedBy, AggregatedValues, SortOrderInput) were generated based on
root_document_type?, causing:OnlineStoreto generate unused derived types (e.g.,OnlineStoreConnection)Solution
Generate derived types based on
directly_queryable?instead ofroot_document_type?:Root derived types (only for directly queryable types):
directly_queryable?Remaining derived types (for all types):