id | title | sidebar_label |
---|---|---|
plugin-fieldAuthorize |
Field Authorize Plugin |
Field Authorize |
The authorize plugin allows us to define field-level authorization to a query:
t.field("postById", {
type: Post,
args: { id: idArg() },
authorize: (root, args, ctx) => ctx.auth.canViewPost(args.id),
resolve(root, args, ctx) {
return ctx.post.byId(args.id);
},
});