Skip to content

Commit

Permalink
Use default values from mock resolver for Relay 3D payload
Browse files Browse the repository at this point in the history
Reviewed By: captbaritone

Differential Revision: D57055435

fbshipit-source-id: 00e0debeb03c48bc757dbb094d7976475f7d9432
  • Loading branch information
alunyov authored and facebook-github-bot committed May 7, 2024
1 parent 00ddca2 commit 24b557a
Show file tree
Hide file tree
Showing 7 changed files with 545 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/relay-test-utils/RelayMockPayloadGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class RelayMockPayloadGenerator {
false,
path,
null,
null,
defaultValues,
),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1891,3 +1891,44 @@ test('generate mock for streamed fragments with if condition false', () => {
{generateDeferredPayload: true},
);
});

test('should generate data for @match with PlainUserNameRenderer_name and use defaults from mock resolvers', () => {
graphql`
fragment RelayMockPayloadGeneratorTest67Fragment on User {
id
nameRenderer {
...RelayMockPayloadGeneratorTest67PlainUserNameRenderer_name
@module(name: "PlainUserNameRenderer.react")
}
}
`;
graphql`
fragment RelayMockPayloadGeneratorTest67PlainUserNameRenderer_name on PlainUserNameRenderer {
plaintext
data {
text
}
}
`;

testGeneratedData(
graphql`
query RelayMockPayloadGeneratorTest67Query @relay_test_operation {
node(id: "my-id") {
...RelayMockPayloadGeneratorTest67Fragment
}
}
`,
{
UserNameRenderer() {
return {
__typename: 'PlainUserNameRenderer',
__module_operation: require('./__generated__/RelayMockPayloadGeneratorTest67PlainUserNameRenderer_name$normalization.graphql'),
data: {
text: 'hello world',
},
};
},
},
);
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 24b557a

Please sign in to comment.