OpenParable
Skip to content
← Back to skills

Migrate Permissions

Development
migrate-permissions

Migrate Permissions is an Agent Skill for development published in the ParabolInc/parabol repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Guide for moving inline auth checks out of GraphQL resolvers and into permissions.ts using graphql-shield rules. Use when adding, reviewing, or migrating authorization logic for mutations or queries.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ParabolInc/parabol/blob/HEAD/.claude/skills/migrate-permissions/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/migrate-permissions, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Permissions

Authorization lives in two places: graphql/public/permissions.ts (preferred) and inline in resolver functions (legacy). The goal is to move all auth into permissions.ts.

How it works

permissions.ts exports a permissionMap that maps GraphQL types/fields to shield rules. composeResolvers.ts wraps each resolver with its rule as a higher-order function — avoiding the overhead of graphql-middleware.

  • '*' wildcard sets a default rule for all fields on a type (e.g., all Mutations default to isAuthenticated)
  • Specific field entries override the wildcard
  • Rules can be composed with and(), or(), not() from graphql-shield

Rules directory: graphql/public/rules/

RuleWhat it checks
isAuthenticatedviewer has a valid auth token
isSuperUserviewer has su role
isTeamMemberauthToken.tms includes the teamId (fast, no DB)
isViewerTeamLeadviewer has isLead on the team member record (DB)
isViewerOnTeamviewer has an active (non-removed) team member record (DB)
isTeamMemberOfMeetingviewer's authToken.tms includes the meeting's teamId (fast)
isMeetingMemberviewer has an actual meetingMembers record (DB, stricter)
isViewerBillingLeaderviewer has BILLING_LEADER or ORG_ADMIN org role
hasOrgRoleviewer has a specific org role (ORG_ADMIN, etc.)
isViewerOnOrgviewer is a member of the org
isOrgTierorg is on a specific tier (enterprise, etc.)
hasPageAccessviewer has viewer or owner access to a page
hasProviderAccessviewer can access an OAuth provider
isNullan arg is null (used for conditional or() rules)
isEnvVarTruean env var is set to true
rateLimitrate limits by perMinute/perHour

Key distinction: isTeamMemberOfMeeting (used for createReflection) only checks team membership and is more permissive. isMeetingMember checks for an actual meeting member record and is stricter. Use isMeetingMember when you need to confirm the viewer has joined the meeting.

Dot-path convention

Rules that take a dotPath accept strings like:

  • 'args.teamId' — top-level arg
  • 'args.input.meetingId' — nested arg
  • 'args.newAgendaItem.teamId' — nested arg
  • 'source.id' — field on the parent resolver's source object
  • 'source.orgId' — field on the parent resolver's source object

Moving auth from resolver to permissions.ts

When extracting inline auth:

  1. Identify the auth check (usually guarded by a comment like // AUTH)
  2. Find the matching rule or compose existing rules with and()/or()
  3. Add the entry to permissionMap in permissions.ts (keep fields alphabetical, '*' first)
  4. Remove the inline check from the resolver, along with any imports that are no longer used
  5. If no existing rule fits and the logic is reusable, ask before creating a new rule — most cases can reuse existing rules

When a new rule is needed (ask first)

  • Auth that depends on an array of IDs (e.g., "team lead for any of these teamIds")
  • Auth that branches on an enum arg (e.g., scope === 'global' | 'org' | 'team')