Registry / auth-security / acl-graphql

acl-graphql

JSON →
library1.0.0jsnpmunverified

A GraphQL ACL (Access Control List) transpiler that generates permission-based GraphQL schemas. Version 1.0.0 is the latest stable release. It transforms declarative ACL rules into GraphQL directives and resolvers, enabling fine-grained field-level access control without modifying existing schema definitions. Differentiates from other auth libraries by focusing on ACL-to-GraphQL transpilation rather than middleware-based enforcement.

npm install acl-graphql
INSTALL
IMPORT
SIG · ACL-GRAPHQL
A
acl-graphql
auth-securityjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AclGraphql
import { AclGraphql } from 'acl-graphql'
const AclGraphql = require('acl-graphql')
ESM-only package since v1.0.0
AclRule
import { AclRule } from 'acl-graphql'
Named export for defining ACL rules
transpileAcl
import { transpileAcl } from 'acl-graphql'
import { transpileACL } from 'acl-graphql'
Function name is camelCase, not PascalCase
default
import AclGraphql from 'acl-graphql'
import { default as AclGraphql } from 'acl-graphql'
Default export also available and preferred

Creates an ACL-transpiled GraphQL schema from type definitions and rules, outputting schema with directives and authorization resolvers.

import { AclGraphql, AclRule } from 'acl-graphql'; import { buildSchema } from 'graphql'; const typeDefs = ` type Query { user(id: ID!): User } type User { id: ID! name: String! email: String! } `; const rules: AclRule[] = [ { role: 'admin', permissions: ['Query.user', 'User.id', 'User.name', 'User.email'] }, { role: 'user', permissions: ['Query.user', 'User.id', 'User.name'] } ]; const acl = new AclGraphql({ typeDefs, rules }); const { schema, resolvers } = acl.transpile(); console.log(schema); // GraphQLSchema with @acl directives console.log(resolvers); // Resolvers enforcing field-level access
Debug
Known issues
breakingAs of v1.0.0, the constructor signature changed: new AclGraphql({ typeDefs, rules }) instead of positional arguments.
fix
Update instantiation to use options object: new AclGraphql({ typeDefs, rules })
affects: >=1.0.0
gotchaRules must use dot notation for fields (e.g., 'User.email'). Nested fields are not supported.
fix
Use flat dot notation for all field paths
affects: >=0.0.0
deprecatedThe 'permissions' field in rules is deprecated since v1.0.0. Use 'fields' instead.
fix
Replace 'permissions' with 'fields' in rule definitions
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: AclGraphql is not a constructor
Using CommonJS require() with ESM-only package
fix
Use ES module import syntax: import { AclGraphql } from 'acl-graphql'
Error: No schema provided
Omitting required 'typeDefs' option in constructor
fix
Pass typeDefs in options object: new AclGraphql({ typeDefs, rules })
Error: Invalid rule - path 'User.email' not found in schema
Rule references a field that doesn't exist in the schema
fix
Verify field path exists in schema definition
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency for GraphQL schema manipulation
Agent activity
66 hits · last 30 days
node
56
Amazon
1
OpenAI (training)
1
Resources
acl-graphql — npm install acl-graphql · libregistry