Fix @key directive missing on deferred indexed types - #1107
Merged
Conversation
jwils
requested review from
BrianSigafoos-SQ,
ayousufi,
bsorbo,
jwondrusch and
myronmarston
as code owners
April 4, 2026 21:12
jwils
force-pushed
the
fix-apollo-key-ordering
branch
from
April 4, 2026 21:15
bd8d2a6 to
a332fcd
Compare
myronmarston
approved these changes
Apr 4, 2026
myronmarston
left a comment
Collaborator
There was a problem hiding this comment.
Left a few questions but LGTM overall.
…complete callbacks The @key directive addition and _Entity union creation in define_apollo_schema_elements ran as an early after_user_definition_complete callback, before types created by later callbacks (e.g. dynamically derived aggregation types) existed. This caused those types to silently lose their @key(fields: "id") directive and be excluded from the _Entity union. Fix by deferring @key and _Entity logic into a nested after_user_definition_complete callback. Ruby's Array#each picks up appended elements during iteration, so this callback runs after all previously registered callbacks, ensuring all types exist first. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jwils
force-pushed
the
fix-apollo-key-ordering
branch
from
April 5, 2026 02:32
a332fcd to
eac18cd
Compare
jwils
enabled auto-merge (squash)
April 5, 2026 02:32
myronmarston
approved these changes
Apr 5, 2026
2 tasks
jwils
added a commit
that referenced
this pull request
Apr 23, 2026
Distills the patterns Myron Marston applies when reviewing merged PRs (naming at the caller's level of abstraction, respond_to? as a code smell, wrapper-class DI pattern, load-bearing tests, RBS/YARD hygiene, etc.) into an edit-first skill. Invoked as /myron-polish, the skill walks the current branch's diff against main and applies fixes directly rather than producing review comments. It loops — re-scan, apply edits, run script/lint --fix / script/spellcheck -w / script/type_check / script/run_gem_specs — until a full iteration makes zero edits and every verification command passes. Capped at 8 iterations. Source material: Myron's review bodies and inline comments on merged PRs #974, #973, #1067, #1066, #1108, #1120, #1131, #1134, #1144, #1107. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
after_user_definition_completecallbacks were missing@key(fields: "id")directives and excluded from the_Entityunion. In practice, this affected indexed types that are dynamically derived during schema finalization (e.g. aggregation types for location/merchant filtering).@keydirective addition intodefine_apollo_schema_elements, which runs as an earlyafter_user_definition_completecallback. Types created by later callbacks don't exist yet when the@keylogic iterates, so they silently lose their federation key.@keyand_Entitylogic into a nestedafter_user_definition_completecallback. Ruby'sArray#eachpicks up elements appended during iteration, so the nested callback runs after all previously registered callbacks — ensuring all types exist first.Test plan
after_user_definition_completecallback and verifies it gets@key(fields: "id")and is included in_Entityschema_artifacts:dumpproduces noschema.graphqldiff (previouslyOrderLocationandOrderMerchantlost their@keydirectives)🤖 Generated with Claude Code