Skip to content

Show schema definition order differences - #1355

Closed
jwils wants to merge 1 commit into
mainfrom
joshuaw/deterministic-field-registry
Closed

Show schema definition order differences#1355
jwils wants to merge 1 commit into
mainfrom
joshuaw/deterministic-field-registry

Conversation

@jwils

@jwils jwils commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Why

An intermittent JRuby failure proves that schema definition order can produce two different GraphQL outputs, but the current assertion stops after counting unique results and hides the actual SDL difference. Capture an actionable diff before choosing a production fix.

What

  • Compare every definition ordering directly against a reference ordering
  • Label failures with both definition orders while retaining the unified raw-SDL diff
  • Clarify that the invariant covers byte-identical schema artifacts, including field order

Risk Assessment

Very low. This changes one test assertion and no production behavior; the same flake may recur, but its next failure will identify the divergent ordering and output.

Validation

  • Focused regression with seed 3570 on CRuby 4.0.0
  • Focused regression with seed 3570 on JRuby 10.0.6.0
  • script/lint

Context

Observed while validating #1305.

@jwils
jwils force-pushed the joshuaw/deterministic-field-registry branch from a5aa001 to ef51bc3 Compare August 16, 2026 14:52
@jwils jwils changed the title Make schema field registration deterministic Show schema definition order differences Aug 16, 2026

@myronmarston myronmarston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really get what benefit this PR provides. It changes how we assert that every definition order produces the same SDL, but does it catch any additional cases or produce better failure output?

I believe the existing test already fully enforces consistently ordered output. But maybe I'm missing something...

# Note: when this spec was written, these first 2 orderings (where `Component` came first) caused infinite recursion.
# At the time, having `Component` come first caused an issue because it caused `ComponentEdge` (with it's
# `node: Component` field) and `ComponentConnection` (with its `nodes: [Component!]!` field) to be generated
# before, `Widget.components` was processed, leading to additional field references to the `Component` type.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# before `Widget.components` was processed, leading to additional field references to the `Component` type.

(I just noticed this while reviewing the overall test...).

Comment on lines +142 to +146
reference_order, reference_result = results_by_definition_order.first

# Also compare the first and last, so that if there are multiple we get a diff showing how they differ.
expect(uniq_results_for_each_ordering.first).to eq uniq_results_for_each_ordering.last
# Compare the raw generated SDL rather than normalizing it through graphql-ruby. Schema definition
# order must not affect field order or any other part of the generated schema artifact.
results_by_definition_order.drop(1).each do |definition_order, result|

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reference_order, reference_result = results_by_definition_order.first
# Also compare the first and last, so that if there are multiple we get a diff showing how they differ.
expect(uniq_results_for_each_ordering.first).to eq uniq_results_for_each_ordering.last
# Compare the raw generated SDL rather than normalizing it through graphql-ruby. Schema definition
# order must not affect field order or any other part of the generated schema artifact.
results_by_definition_order.drop(1).each do |definition_order, result|
(reference_order, reference_result), *remaining_results = results_by_definition_order
# Compare the raw generated SDL rather than normalizing it through graphql-ruby. Schema definition
# order must not affect field order or any other part of the generated schema artifact.
remaining_results.each do |definition_order, result|

I was initially confused by the drop(1). Note: I haven't tried this, so it may not quite work as I've written it. Pattern matching syntax might be needed to make it work.

@jwils

jwils commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Doesn't do anything yet, but I am trying to reproduce https://github.com/block/elasticgraph/actions/runs/31920698193/job/95100012949?pr=1305 with more debug info. I think a flaky test, but not enough info on the failure? Let me know if you have any suggestions. Otherwise I may stop worrying about it since I can't seem to reproduce it.

@jwils

jwils commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

jruby/jruby#9591 is the root cause I believe.

@jwils jwils closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants