Skip to content

envelop

github-actions[bot] edited this page Oct 14, 2026 · 3 revisions

envelop

The envelop integration — the optional entry point, @vantreeseba/graphql-casl/envelop.

Remarks

applyPermissions wraps a schema up front, which needs a schema you own and can replace. That is awkward on Apollo Server 4+, on federated gateways, and anywhere the schema is built or swapped for you. useGraphQLCasl hooks resolvers as envelop hands them over, so the same map works wherever envelop does — GraphQL Yoga, Apollo with the envelop integration, Hive Gateway, graphql-ws.

The permission logic itself is not reimplemented here: the plugin calls resolvePermissions, so wildcard precedence, fallbackRule coverage, error control, filtering and map validation behave exactly as they do under applyPermissions. One thing it can do that applyPermissions cannot: under onDeny: 'filter' it sees the finished result, so the denials a field could not carry itself are reported without any call to reportDenials.

@envelop/core and @envelop/on-resolve are optional peer dependencies — they are only needed by consumers who import this entry point, which is why the main entry point still has no runtime dependencies of its own.

Example

import { createYoga } from 'graphql-yoga';
import { useGraphQLCasl } from '@vantreeseba/graphql-casl/envelop';

const yoga = createYoga({
  schema,
  plugins: [useGraphQLCasl<Resolvers>({ permissions, fallbackRule: deny })],
});

Interfaces

Functions

API Reference

Clone this wiki locally