Allow missing fields from defer payloads #5083
Open
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.
The current spec proposal for
@defer
requires that servers do not send the same field multiple times in response payloads. If the same field is in both a deferred and non-deferred fragments, or two different deferred fragments, Relay expects this field to be in each of the corresponding responses or else it will throw an error like:This PR adds a new flag
deferDeduplicatedFields
which allows Relay to accept payloads with missing fields. The current defer spec guarantees a fragment will not be marked as completed until all of the fields have been returned, so in this case the relay store should already have the fields that are missingNote: There are still major differences between the response format in the latest defer spec and what Relay expects. This PR does not attempt to make Relay compatible with the spec, but rather allow a transformation to be done in the network layer to convert the current response format into something Relay can accept. There is an example of a working transformation in https://github.com/robrichard/defer-relay-example