facebook / facebook/relay

Deduplicating subscription responses that were already optimistically loaded on store

Open
#3,060 9 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Hi!

I'll try to explain my case without codes, I think it will be more easy to understand, if this is supported already, I won't bother you by making you fix my code

It's a chat feature.
(I'm a user)

1 - I send a message
2 - optimisicResponse is set, it will already paint to messages feed
3 - server fires responses to subscribed users, not only who will receive, but also who sent is subscribed if one more window is open.
4 - sometimes this subscription payload arrives before the mutation payload, so it will flicker my page for some miliseconds, as both will be rendered. It seems there's no way to know they refer to the same mutation... exept for **clientMutationId**.

My attempt to fix this was trying to delete the temporary optimistic response, by creating this with the clientMutationId as ID then ```store.delete(clientMutationId)``` on subscription updater. But I was not able to delete this node from connection, why won't this work this way?

I didn't find anywhere on Relay Modern Docs how to deduplicate this case of same referencing, thats why I'm posting here (mutation and subscription to same data)

ps.
also tried with ```ConnectionHandler.deleteNode(connection, clientMutationId)```

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.