Prisma automatically makes a subscription for each schema type in the database. For the server using this subscription what is the best way to funnel through this functionality.
Should this work as expected? -
user: {
subscribe: async (parent, args, ctx, info) => {
return ctx.db.subscription.user({}, info)
}
}
Or should we use pubsub like the counter example? -
counter: {
subscribe: (parent, args, { pubsub }, info) => {
const channel = Math.random().toString(36).substring(2, 15) // random channel name
let count = 0
setInterval(() => pubsub.publish(channel, { counter: { count: count++ } }), 2000)
return pubsub.asyncIterator(channel)
},
},