You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've done a good bit of research on using pubsub in the SubscriptionServer onConnect and onDisconnect methods and haven't found any ways to do this or work arounds. I'm wanting to publish events to other clients when subscriptions open/close with a specific client.
Example of what I would like to be able to do
constsubscriptionServer=SubscriptionServer.create({
schema,context: authMiddleware,
execute,
subscribe,onConnect(connectionParams){consttoken=connectionParams.authToken.split(' ').pop().trim();if(token){try{const{ data }=jwt.verify(token,secret,{maxAge: expiration});console.log(`${data.username} has connected`);// I would like to publish this event to the subscriptions in my resolverspubsub.publish('USER_CONNECTED',{/* data to be passed */});returndata}catch{console.log('Invalid token');}}returnfalse;},onDisconnect(_,context){context.initPromise.then(asyncuser=>{if(user){console.log(`${user.username} has disconnected`)// I would like to publish this event to the subscriptions in my resolverspubsub.publish('USER_DISCONNECTED',{/* data to be passed */});}})}},{server: httpServer,path: server.graphqlPath});
I've done a good bit of research on using pubsub in the SubscriptionServer onConnect and onDisconnect methods and haven't found any ways to do this or work arounds. I'm wanting to publish events to other clients when subscriptions open/close with a specific client.
Example of what I would like to be able to do
My resolvers look like:
The text was updated successfully, but these errors were encountered: