Plugins

Field Authorize


Field Authorize

The authorize plugin allows us to define field-level authorization to a query:

1t.field('postById', {
2 type: Post,
3 args: { id: idArg() },
4 authorize: (root, args, ctx) => ctx.auth.canViewPost(args.id),
5 resolve(root, args, ctx) {
6 return ctx.post.byId(args.id)
7 },
8})
Edit this page on Github