Does anybody have an example of using `nexus-plugi...
# graphql-nexus
s
Does anybody have an example of using
nexus-plugin-shield
with
@nexus/schema
? I can only find nexus framework examples with
use
.
r
You can directly use
graphql-shield
with
@nexus/schema
. Have a look at this repo: https://github.com/ryands17/nexus-auth/blob/master/src/utils/rules.ts
s
Thanks Ryan. I need to use the auth token provided in one of my resolvers. With
nexus-plugin-shield
I could do it as
ctx.req.headers.authorization
. How would I do that with graphql-shield?
r
You would need to do something like this: https://github.com/ryands17/nexus-auth/blob/master/src/utils/helpers.ts#L30-L56 And pass the context here if you’re using apollo-server.
s
Thanks 🙂 Do we have a doc somewhere with all these examples in?
r
I don’t think there’s a doc, but we should have them in our examples repo.
s
r
Oh, Good to know about this plugin! Thanks