Add regression test for RelayResponseNormalizer nested-list-with-abstract-leaf (#5056)#5268
Open
markselby9 wants to merge 2 commits into
Open
Add regression test for RelayResponseNormalizer nested-list-with-abstract-leaf (#5056)#5268markselby9 wants to merge 2 commits into
markselby9 wants to merge 2 commits into
Conversation
…ract-leaf bug (facebook#5056) Adds a regression test in RelayResponseNormalizer-test.js demonstrating the bug captbaritone identified in facebook#5056: when a plural field contains items that are themselves arrays of abstract-typed records, the normalizer's _getRecordType receives an array and fails with "Expected a typename for record [...]". The test schema does not model nested lists ([[T!]!]!), so the test sends a doubly-nested payload to a plain plural-of-abstract field (User.actors: [Actor]). This exercises the same _normalizePluralLink -> _getRecordType code path described in the issue. Test asserts current (buggy) behavior via toThrow. The fix is left to the maintainer; flip the assertion when the underlying bug is fixed.
…ribe block
Reviewer feedback: the regression test was nested inside
describe('User-defined getDataID') > describe('plural fields'), but
the test exercises no getDataID behavior — it just demonstrates the
malformed-payload path on User.actors and asserts the unhelpful
Invariant Violation.
Hoists the test to top-level under describe('RelayResponseNormalizer'),
near the existing scalar-warning cluster. The test can no longer reuse
the closure-scoped BarQuery (which lived in the inner describe), so it
declares its own inline graphql literal — adds one new
__generated__/RelayResponseNormalizerTest5056Query.graphql.js artifact.
Trade: honest placement vs. one extra generated file.
49ebac1 to
8207df4
Compare
This was referenced May 6, 2026
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
Adds a regression test in
RelayResponseNormalizer-test.jsthat demonstrates the bug @captbaritone identified in #5056: when a plural field contains items that are themselves arrays of abstract-typed records,_normalizePluralLink→_getRecordTypereceives an array (not a record) and throwsExpected a typename for record [...].This is test-only per @captbaritone's request in #5056 (comment) — no production code changes. The test asserts current (buggy) behavior; whoever fixes the underlying bug should flip the assertion.
The reported schema shape
[[MyType!]!]!isn't modeled by the OSS test schema, so the test feeds a doubly-nested payload to a regular plural-of-abstract field (User.actors: [Actor]). The runtime code path exercised is the same one described in the issue. The regex assertion is anchored on the JSON-stringified open bracket so the test fails loudly if a different_getRecordTypecall site fires first.Refs #5056.
Commits
describe('User-defined getDataID') > describe('plural fields')reusing closure-scopedBarQuery.describe('RelayResponseNormalizer', …)since it doesn't exercise getDataID behavior. Tradeoff: lostBarQueryclosure reuse, so the PR now ships one new__generated__/RelayResponseNormalizerTest5056Query.graphql.jsartifact (137 lines, standard codegen output viarelay-compiler@0.0.0-main-38ad9e13).Test plan
yarn jest packages/relay-runtime/store/__tests__/RelayResponseNormalizer-test.js -t '5056'— 1 passedRelayResponseNormalizer-test.jssuite still passes (61 total, was 60)