-
Beta Was this translation helpful? Give feedback.
Answered by
enisdenjo
Mar 8, 2023
Replies: 1 comment 2 replies
-
You can use the context extra field which is shared between the hooks for distinct connections: const serverCleanup = useServer(
{
schema,
- onConnect: async () => {
+ onConnect: async (ctx) => {
+ ctx.extra.userName = getUserName()
console.log('User connected')
},
- onClose() {
+ onClose(ctx)
console.log('User disconnected')
userResolvers.Mutation.deleteUser({
- name: 'John'
+ name: ctx.extra.userName
})
},
},
wsServer
) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
enisdenjo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the context extra field which is shared between the hooks for distinct connections: