Ippo
05/23/2020, 3:00 AMRyan
05/25/2020, 8:34 AMconst permissions = shield({
Query: {
frontPage: not(isAuthenticated),
fruits: and(isAuthenticated, or(isAdmin, isEditor)),
customers: and(isAuthenticated, isAdmin),
},
Mutation: {
addFruitToBasket: isAuthenticated,
},
Fruit: isAuthenticated,
Customer: isAdmin,
})
const server = new GraphQLServer({
typeDefs,
resolvers,
middlewares: [permissions],
context: (req) => ({
...req,
user: getUser(req),
}),
})
You can add permission based authorization as a simple resolver.Ippo
05/25/2020, 5:58 PMIppo
05/25/2020, 5:58 PMIppo
05/25/2020, 5:59 PMIppo
05/25/2020, 5:59 PMRyan
05/26/2020, 6:28 AM