Subscriptions help #732
-
4 years ago I wrote a full stack JS app with subscriptions using Apollo and Prisma1, and PostgresPubSub from graphql-postgres-subscriptions 1.0.5. For example I need subscriptions working on a User entity (let's assume User just has 'id' and 'name' for now). I need a subscription only for a certain user.id that had a mutation type of UPDATED (not CREATED or DELETED) and to get back only the info I ask for (in this case 'id' and 'name'). The previous autogenerated server graphql looked like this 4 years ago:
The Apollo client gql (on the web client) looked like this:
I know this is a broad question, but is this possible using Pothos SmartSubscriptions, and are there any examples of it? If it's not possible with SmartSubscriptions, would I be able to use something like builder.subscriptionField? Here's my attempt at SmartSubscriptions:
which results in the following auto-generated in the schema.graphql:
so I don't quite understand how to get the mutationType out of that. If I can't do any or all of this using Pothos, how do I go about adding subscriptions to my graphql schema that are apart from Pothos-generated code? I will need file uploads and authentication next and not everything can be configured in Pothos the way I might specifically need it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Added an example here, hope this helps: https://github.com/hayes/pothos/tree/main/examples/prisma-subscriptions The short answer is that prisma doesn't support automatically publishing events when things change, so you will need to manually "publish" events when you mutate data. The exact format for how you handle this is up to you, but hopefully the example above will help |
Beta Was this translation helpful? Give feedback.
Added an example here, hope this helps: https://github.com/hayes/pothos/tree/main/examples/prisma-subscriptions
The short answer is that prisma doesn't support automatically publishing events when things change, so you will need to manually "publish" events when you mutate data. The exact format for how you handle this is up to you, but hopefully the example above will help