Skip to content
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

How to update all subscribed clients except the one making the changes #54

Closed
Vrudh opened this issue Mar 29, 2017 · 2 comments
Closed

Comments

@Vrudh
Copy link

Vrudh commented Mar 29, 2017

I tried to integrate graphql-subscriptions and it worked out pretty good, But it broke the app (which i can fix easily.. but i don't think that's the right decision)

Subscriptions sends the updates for everything i am subscribed to, But when i create a new item, The store is already updated from the mutation i just ran, but Subscription kicks in and runs the logic which updates the store again.. And i get the duplicate key warning.

I can and have fixed this by checking if a record already exists and then handling the update., But this means that the updates are still sent to all the subscribed clients who want to be notified of the changes.

Is there any way to send updates to all the subscribed clients, Except the one making the changes/operations (CRUD), without writing lot of codes?

Ofcourse i can use setupFunctions filter but if the same user has opened the app in different tabs, this will not work out.

What do you recommend, How should i move forward with this.

@NeoPhi
Copy link
Contributor

NeoPhi commented Apr 3, 2017

Unfortunately there is no support for this that I know of. The source of a mutation is completely separate from the message that triggers the subscription so there is no easy way to correlate the two independent events. Your approach of handling the issue client side is what we use as well. It could even be, based on your system architecture, that a client sees the subscription message before the mutation result.

@Vrudh
Copy link
Author

Vrudh commented Apr 5, 2017

It could even be, based on your system architecture, that a client sees the subscription message before the mutation result

Yes, That's definitely possible, I didn't check for that.

Back to updating mutation queries with a helper function, This will make things little easier.

@Vrudh Vrudh closed this as completed Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants