Skip to content

Commit 71931fd

Browse files
Merge pull request #2115 from NimitzDEV/patch-1
docs(graphql): graphql-ws context value example
2 parents 52a2454 + 46df9b9 commit 71931fd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

content/graphql/subscriptions.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,14 @@ If you're using the `graphql-ws` package, the signature of the `onConnect` callb
334334
subscriptions: {
335335
'graphql-ws': {
336336
onConnect: (context: Context<any>) => {
337-
const { connectionParams } = context;
338-
// the rest will remain the same as in the example above
337+
const { connectionParams, extra } = context;
338+
// user validation will remain the same as in the example above
339+
// when using with graphql-ws, additional context value should be stored in the extra field
340+
extra.user = { user: {} };
339341
},
340342
},
343+
context: ({ extra }) => {
344+
// you can now access your additional context value through the extra field
345+
}
341346
},
342347
```

0 commit comments

Comments
 (0)