Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 385 Bytes

plugin-fieldAuthorize.md

File metadata and controls

18 lines (16 loc) · 385 Bytes
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);
  },
});