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 call this subscription when a user is connected to a session:
session.resolvers.js
connectUserToSession: async(_,args)=>{constsession=awaitprisma.session.update({where: {id: Number(args.sessionId)},data: {players: {connect: {id: Number(args.userId)}}},include: {players: true,host: true}})pubsub.publish('USER_JOINED_SESSION',{userJoinedSession: session})returnsession},// working on thisuserJoinedSession: {subscribe: withFilter(()=>pubsub.asyncIterator('USER_JOINED_SESSION'),(payload,variables)=>{console.log(variables)returntrue},),},
My goal is to send notifications only to users who are also connected to that session. To achieve this I want to to send the session object that a user is connected to from the client to the server and then use that in the withFilter().
The problem I'm encountering is that in the client when the service is initiated it initiates the subscriptions with the value of this.sessionSubject.getValue()?.id which is null (since a user hasn't joined a session yet).
But this value never gets updated. How can I achieve that?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a service, in this service I initiate a subscription:
session.service.ts
I call this subscription when a user is connected to a session:
session.resolvers.js
My goal is to send notifications only to users who are also connected to that session. To achieve this I want to to send the session object that a user is connected to from the client to the server and then use that in the
withFilter()
.The problem I'm encountering is that in the client when the service is initiated it initiates the subscriptions with the value of
this.sessionSubject.getValue()?.id
which isnull
(since a user hasn't joined a session yet).But this value never gets updated. How can I achieve that?
Beta Was this translation helpful? Give feedback.
All reactions