Skip to content
Snippets Groups Projects
Commit 557dc56d authored by jgutix's avatar jgutix
Browse files

fix(middleware): ensure rules are not empty before applying shield

parent f17b2655
No related branches found
No related tags found
1 merge request!2feat(middleware): add helpers for authorization middleware
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
const config = require('config')
const isEmpty = require('lodash/isEmpty')
const { applyMiddleware } = require('graphql-middleware')
const { shield } = require('graphql-shield')
let schema = require('pubsweet-server/src/graphql/schema')
if (config.has('permissions')) {
schema = applyMiddleware(schema, shield(config.get('permissions')))
const permissions = config.has('permissions') && config.get('permissions')
if (permissions && !isEmpty(permissions)) {
schema = applyMiddleware(schema, shield(permissions))
}
module.exports = schema
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment