Prisma1: Multiple identical subscriptions on CREATE

Created on 29 Jan 2018  路  13Comments  路  Source: prisma/prisma1

Current behavior
Prisma local send duplcate subscriptions.

Reproduction
Open more than 2 playground and start same subscription requests and send create request.

For 3 connections receive three notifications in each window. For 5 - 5 notifications in each window. And etc...

a411b431d4

Expected behavior?
One notification per one ws-connection.

Most helpful comment

@marktani If I understand correctly, I am only seeing this issue when connecting indirectly via graphql-yoga GraphQLServer. Running graphql playground I can test subscriptions on the database and application side. The multiple firings only occur on the app side. Each message is sent to each client multiple times equal to the number of clients that have connected since starting the server. Subscriptions in graphql-yoga that don鈥檛 use prisma-bindings work as expected.

All 13 comments

Same

Are you experiencing this when connecting directly to your Prisma endpoint, or when connecting indirectly via another GraphQL Server?

@marktani i do not us another GraphQL server. I use prisma local. But this problem i have when connect via appolo-client too. In termanal logs i receive multiple notifications too.

@marktani If I understand correctly, I am only seeing this issue when connecting indirectly via graphql-yoga GraphQLServer. Running graphql playground I can test subscriptions on the database and application side. The multiple firings only occur on the app side. Each message is sent to each client multiple times equal to the number of clients that have connected since starting the server. Subscriptions in graphql-yoga that don鈥檛 use prisma-bindings work as expected.

Perhaps this is due to the fact that graphql-yoga (or any other server) acts as a proxy server when used with prisma. Browser connections would be made with the proxy server, not the prisma endpoint. When the browser is closed, the underlying prisma server is unaware and continues to try and send messages to these ghost clients. This would explain why there is no issue with subscriptions made directly with the prisma endpoint. And also why there is no issue with graphql-yoga subscriptions that don't rely on prisma.

@flintc i agree

I have this problem with react-native. Does anyone know how to solve this problem?

Isn't this related to this issue?
https://github.com/graphcool/graphql-yoga/issues/101#event-1458329589

@oiojin831 did you try upgrading your versions as discussed in the link you mentioned?

@marktani Yes, this is not a problem for me anymore.
I was mentioning this cause I thought this can be closed 馃槃

Hey @oiojin831, that's what I thought 馃檪 Thanks for the confirmation!

@Fi1osof, I'm closing this issue as it seems resolved, please open another one if you're still encountering any problems!

@marktani So, I was having this issue as well, where I would create an item and the subscription would update the query multiple times. Its seems this issue has been fixed (meaning that the query is only updated once) but when I'm logging all the queries, I still see "mutation: CREATED" an increasing number of times until I do a browser refresh.

Here's the mutation in playground.
screen shot 2018-02-16 at 4 59 38 pm

Here's the subscription in playground. It only gets one response.
screen shot 2018-02-16 at 5 00 51 pm

HOWEVER, here is what is logged to the terminal. This is after creating several rules.

screen shot 2018-02-16 at 5 01 37 pm

So, I'm concerned this is still an issue.

yes still an issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fi1osof picture Fi1osof  路  3Comments

marktani picture marktani  路  3Comments

marktani picture marktani  路  3Comments

AlessandroAnnini picture AlessandroAnnini  路  3Comments

tbrannam picture tbrannam  路  3Comments