-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Customer middleware is called after shield plugin.
● nexus:server listening -- url: 'http://localhost:4000/graphql'
● nexus:server:request Authentication Rule
● nexus:server:request Before Resolver
● nexus:server:request After Resolver// app.ts
schema.middleware((_config) => {
return async (root, args, ctx, info, next) => {
ctx.log.info('Before Resolver')
await next(root, args, ctx, info)
ctx.log.info('After Resolver')
}
})
use(
shield({
rules,
}),
)
// permissions.ts
const isAuthenticated = rule({ cache: 'contextual' })(
async (parent, args, ctx, info) => {
ctx.log.info('Authentication Rule')
const userId = ctx.req.headers.authorization
return Boolean(userId)
},
)I would expect the custom middlewares, defined before the shield plugin, to be called before the shield rules.
I'm not sure if this is a bug originating from this plugin, or the Nexus core's plugin/middleware behavior is bugged.
Repo for reproduction: https://github.com/bkiac/nexus-graphql-middleware-order
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels