-
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
Change clientMutationID invariant to a conditional check to work with subscriptions #736
Conversation
I updated the tests to use a |
nodeID | ||
const clientMutationID = getString(payload, CLIENT_MUTATION_ID); | ||
// subscriptions won't have a clientMutationID so never optimistically add | ||
if (clientMutationID) { |
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.
How about changing the outer if
condition to if (operation instanceof RelayQuery.Mutation)
, and move the invariant on clientMutationId
inside the if block? This will get the intended effect of not running the invariant for subscriptions, while keeping the validation for mutations.
@eyston Sorry for the delay in providing feedback: this is great. Other than the one piece of feedback above, this is ready to import. |
…ed on operation type
…in the subscription blogpost
Updated with feedback -- which was way smarter check condition. Also rebased off master to fix CI. I can squish this or something too, dunno conventions! Sorry for delay myself. Busy week! Good times. |
@eyston thanks for this, looks great and we'll import next week. There's no need to squash commits for a single PR, our tool imports the combined patch. Thanks for offering though ;-) |
@josephsavona Any update on getting this merged? Same for #779. |
Following up on this – did this code ever get pulled in? Right now it's not possible to apply a RANGE_ADD subscription response without setting a dummy |
I think we can solve this by moving: writeRelayUpdatePayload.js#L320-L326 to writeRelayUpdatePayload.js#L376-L383 like it is done here: RelayStoreData.js#L376-L383 |
I feel like this PR does the trick pretty well, though. |
Ping! We're working around this in relay-subscriptions right now by adding a dummy |
Reviewed By: josephsavona Differential Revision: D3889498 fbshipit-source-id: e4bb5bd2e5d2b8f7b2cfbb58ae499b4af1a846ad
I'm working on #541 and
handleRangeAdd
inwriteRelayUpdatePayload
has an invariant onclientMutationID
being in the payload. This won't be the case for a subscription payload configured as a RANGE_ADD.From what I can tell the
clientMutationID
is used in order to link up a temporary node ID added by an optimistic mutation with the real one from the mutation payload. This won't be necessary for subscriptions.I replaced the invariant with a conditional check on the
clientMutationID
. I also duplicated the test the for non-optimistic RANGE_ADD's without aclientMutationID
which I'm not sure is necessary or not.