crystal icon indicating copy to clipboard operation
crystal copied to clipboard

GraphQL subscriptions?

Open gijo-varghese opened this issue 9 years ago • 4 comments

First of all thanks for the amazing project

Does Postgraphl support subscriptions? I couldn't find any doc about it. If it's not added in Postgraphql can I use Posgraphql + custom coded subscriptions together?

Can we write custom mutations? For example, if a new user is added to the database I want to send him an email.

In future, we'll have master-slave infra for our database for horizontal scaling. Maybe 1 database with for insert/update/delete operations and some replicas (2-5) for reading operations. So how can I tell Postgraphql that use this database for queries and this database for mutations etc?.

gijo-varghese avatar Sep 05 '17 02:09 gijo-varghese

Does Postgraphl support subscriptions? I couldn't find any doc about it. If it's not added in Postgraphql can I use Posgraphql + custom coded subscriptions together?

The current discussion around Subscriptions is in #92.

Can we write custom mutations? For example, if a new user is added to the database I want to send him an email.

Yes, in v4 (which is going to move from alpha to beta status soon) - see https://www.graphile.org/postgraphile/extending/#wrapping-an-existing-resolver

In future, we'll have master-slave infra for our database for horizontal scaling. Maybe 1 database with for insert/update/delete operations and some replicas (2-5) for reading operations. So how can I tell Postgraphql that use this database for queries and this database for mutations etc?.

We don't have this functionality yet, but it wouldn't be much work to add. Priority at the moment is to get v4 out.


To keep things manageable I'm going to close this issue as I think it's solved; but if not or you require further help please re-open it.

benjie avatar Sep 05 '17 09:09 benjie

Assume that we have one auto generated mutation 'CreateUser' from postgraphile for table User. I want to override or you can say I want to publish newly created User on graphql-subscriptions. Is it possible for us to override 'CreateUser' mutation in our nodejs code may be something like below: extend type CreateUser(Name:String!) and then in resolver pubsub.publish("USER_CREATED", { user}). If this is not working, probably I have to duplicate createUser with different name and then publish the same on subscription channel. I am not big fan of mixing postgre sql in nodejs to listen and notify the event

sspsinha avatar Nov 05 '19 09:11 sspsinha

You can achieve that with makeWrapResolversPlugin, yes.

benjie avatar Nov 05 '19 12:11 benjie

@benjie Thank You so much. It works

sspsinha avatar Nov 07 '19 09:11 sspsinha