Open drukerez opened 5 years ago
Did you find a solution for this? We are seeing the same thing and really also hope that we can keep the partial responses.
For fields for which you don’t want to supply an optimistic value you can pass undefined
, and Relay will skip over it (and not warn)
Did you find a solution for this? We are seeing the same thing and really also hope that we can keep the partial responses.
I'm planning to write a wrapper around optimistic updater that will update the provided fields without the validation. Haven't gotten around to it yet tho so, lots of console warnings for now...
Hey @drukerez, did you ever come up with a workaround here? Would love to hear more if so.
Hey @drukerez, did you ever come up with a workaround here? Would love to hear more if so.
@steobrien haven't spent time on this. Still loads of console warnings 😢
You can use key: undefined
for any fields that you don't want to explicitly update. The idea is that usually forgetting a key is a mistake, so you have to be intentional about which values you provide and which you don't. This way if the mutation should provide a new field you get alerted to that.
Great, thanks. Good to know.
I ended up refactoring my approach to avoid the error, and it eventually led to a much better solution.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
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
optimisticResponseto 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 :)