@graphql-authz/envelop-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

@graphql-authz/envelop-plugin

Configuring for Envelop

Ensure context parser is configured to perform authentication and add user info to context

  const getEnveloped = envelop({
    plugins: [
      ...
      useExtendContext(req => ({
        user: someHowAuthenticateUser(req.get("authorization"))),
      })),
      ...
    ]
  });

or

  getEnveloped({
    user: someHowAuthenticateUser(req.get("authorization"))),
  });

Add plugin to envelop

  import { authZEnvelopPlugin } from "@graphql-authz/envelop-plugin";
  
  const getEnveloped = envelop({
    plugins: [
      ...
      authZEnvelopPlugin({ rules })
      ...
    ]
  });

For Directives usage

Apply directive transformer to schema

import { authZDirective } from '@graphql-authz/directive';
import { authZEnvelopPlugin } from "@graphql-authz/envelop-plugin";

const { authZDirectiveTransformer } = authZDirective();

const transformedSchema = authZDirectiveTransformer(schema);

const getEnveloped = envelop({
  plugins: [
    useSchema(transformedSchema),
    authZEnvelopPlugin({ rules })
    ...
  ]
});

For AuthSchema usage

Pass additional parameter authSchema to authZEnvelopPlugin

import { authZEnvelopPlugin } from "@graphql-authz/envelop-plugin";
  
const getEnveloped = envelop({
  plugins: [
    ...
    authZEnvelopPlugin({ rules, authSchema })
    ...
  ]
});

Package Sidebar

Install

npm i @graphql-authz/envelop-plugin

Weekly Downloads

674

Version

1.0.5

License

MIT

Unpacked Size

3.56 kB

Total Files

5

Last publish

Collaborators

  • graphql-authz