facebook / facebook/relay

Suppress warnings for partial optimistic responses

Open
#2,808 8 comments 10 reactions 0 assignees View on GitHub
wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

tl;dr;
Are partial (a subset of the server response fields) optimisticResponses allowed and are they and okay practice? If so, what's the correct way to suppress warnings about them?

Details:
I've started encountering new warnings after upgrading relay:
`Warning: validateMutation: Expected `optimisticResponse` to match structure of server response for mutation...`

Everything seems to work fine as before, except that I can't get rid of these warnings. I couldn't find any documentation saying whether partial responses are allowed or not.

First question: Are partial optimisticResponses allowed? If so are there any practices to follow around them?

The only way around this that I could find was used in this test:
https://github.com/facebook/relay/commit/6666b5044258b47a97e6ec0e0fd331074a721a4f#diff-2a442c652e29b1836dbd23b42cc3f27fR117

Second question: Is this the approach I should be taking to suppress the warnings? If not, what's the right approach?

When trying the above approach shown in the test, I couldn't get it to work. The problem seems to be that in the validator, the type of the field being validated never seems to be an InlineFragment. I'm not sure if this has something to do with the fragment spread or my customer relay compiler.

Third question: If the above approach is the correct one. How do I ensure that those InlineFragments are being validated the way that they are supposed to, or debug the situation? If this question is not clear enough then I'm happy to provide more context.

Thanks! I do hope that partial optimisticResponses are still supported :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.