-
StoryAs a server developer I would like to use auth directives on my schema to mark certain subscriptions as "User" or "Admin" only. Apollo gives a good tutorial on how to accomplish this: https://www.apollographql.com/docs/apollo-server/security/authentication/#with-custom-directives. An example of this might look like:
It is however not clear how to achieve this in graphql-ws. So it would be useful to have an example to see how this could be done. Acceptance criteria
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Auth directives is framework/implementor schema specific feature, not a part of You can use the |
Beta Was this translation helpful? Give feedback.
Auth directives is framework/implementor schema specific feature, not a part of
graphql-ws
which is just a transport library.You can use the
context
hook to populate the GraphQL context with whatever you please and leverage the auth directives within your schema implementation. I also recommend taking a look atgraphql-shield
.