Ocelot-Social/src/middleware/permissionsMiddleware.js
Robert Schäfer 15d9178369 Install and configure eslint
Fix all violations but one - there is a mock in our authentication.
2018-12-03 18:05:28 +01:00

26 lines
545 B
JavaScript

import { rule, shield, allow } from 'graphql-shield'
const isOwner = rule()(async (parent, args, ctx, info) => {
return ctx.user.id === parent.id
})
// Permissions
const permissions = shield({
Query: {
statistics: allow
// fruits: and(isAuthenticated, or(isAdmin, isModerator)),
// customers: and(isAuthenticated, isAdmin)
},
Mutation: {
// addFruitToBasket: isAuthenticated
// CreateUser: allow
},
User: {
email: isOwner,
password: isOwner
}
// Post: isAuthenticated
})
export default permissions