-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modifying @relay_test_operation to write metadata for client fields #4047
Modifying @relay_test_operation to write metadata for client fields #4047
Conversation
33ee219
to
175d101
Compare
apply_transform_for_test(fixture, |program| { | ||
generate_test_operation_metadata(program, &test_path_regex) | ||
}) | ||
let parts: Vec<_> = fixture.content.split("%extensions%").collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I referenced other mod.rs
files in order to get this working
This comment was marked as outdated.
This comment was marked as outdated.
a47df41
to
288a802
Compare
288a802
to
8e15a4d
Compare
8e15a4d
to
7e6ce8d
Compare
74f70f4
to
031b3c0
Compare
What's the rationale for doing this conditionally with a FeatureFlag instead of doing this unconditionally? |
It was along the same line as the feedback I got here in a previous PR with client field changes. The metadata exposed to MockPayloadGenerator is now more rich for client fields — this could break systems(like snapshot tests or other assertions) that implicitly depend on the behavior today. I was thinking the flag could be removed in the next major version of Relay and at that point we could make this behavior the new default! |
description: String | ||
} | ||
==================================== OUTPUT =================================== | ||
query ClientFieldsQuery @__metadata(relayTestingSelectionTypeInfo: {node: {enumValues: null, nullable: true, plural: false, type: "Node"}, node.id: {enumValues: null, nullable: false, plural: false, type: "ID"}, node.name: {enumValues: null, nullable: true, plural: false, type: "String"}, node.client_info: {enumValues: null, nullable: true, plural: false, type: "ClientInfo"}, node.client_info.name: {enumValues: null, nullable: true, plural: false, type: "String"}, node.client_info.description: {enumValues: null, nullable: true, plural: false, type: "String"}}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the new behavior with the feature flag enabled. This extra metadata will allow MockPayloadGenerator
to auto-mock client fields when they're not provided in the associated resolver
If we don't add a feature flag and do this unconditionally... all that'd do is add additional metadata about to the generated artifact for any existing operations that have the That in itself isn't something I'd consider a breaking change. The output from calling That's why I find the FeatureFlag to be an overkill here. Am I missing something? |
I'm not sure that's true since my last commit only gave support for providing manual client data to a resolver. I never made any changes to But now with this latest changes those artifacts will update will update at compile time — which doesn't care about what options are passed to MockPayloadGenerator since that's a runtime thing. Edit: reading your comment more closely it seems that you realize this 🤦. If you think it doesn't count as a breaking change I'm happy to remove the feature flag logic! |
Yes the generated artifacts will get changed.
this is the only place we ever read If I'm reading So the only cases where runtime behavior changes is when
(it's possible I'm being oblivious to something that you're seeing. so please do call me out on anything I'm asserting incorrectly or overlooking.) |
@voideanvalue nope that's correct! I had in mind the hyrum's law feedback from the last PR. But yeah I can update things next week 👍 |
5697a2e
to
91e4691
Compare
91e4691
to
b0a2f00
Compare
@voideanvalue just updated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@alunyov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Problem
There were recent changes to allow support for mocking client side fields with MockPayloadGenerator. Now that these fields can be used we need to make sure
@relay_test_operation
writes associated metadata for them during artifact generation.Solution
Add a new
FeatureFlag
,enable_mock_client_data_metadata
, to control whether or not client data gets extra metadata generated when@relay_test_operation
is applied to a query.Then, modify the
!field.is_extension
checks in bothScalarField
andLinkedField
patterns to also look for the feature flag value before skipping client data.Finally, add new test cases to support the new variations with client side schema fields. The
mod.rs
file was changed to create a local schema instance that incorporates client side schema extensions.