@paljs/plugins
This is the recommended package for production applications. PrismaSelect optimizes your GraphQL queries while you maintain full control over your API — you decide which operations to expose and how to handle authorization.
Introduction
GraphQL plugins for Prisma that provide automatic field selection optimization. The main export, PrismaSelect, analyzes GraphQL queries and generates optimized Prisma select/include objects — only fetching the fields actually requested.
Why use PrismaSelect?
- Secure — You write your own resolvers with proper authorization
- Performant — Only fetches requested fields, prevents N+1 queries
- Framework agnostic — Works with Apollo, Yoga, Mercurius, and any GraphQL server
- Type safe — Full TypeScript support with generated types
Installation
Peer Dependencies
@prisma/client^6 or ^7graphql^15 || ^16
PrismaSelect
Basic Usage
Typed Usage (v9)
With @paljs/generator, you get a ModelsObject type that eliminates any:
With Default Fields
Always include specific fields regardless of the GraphQL query:
With Field Exclusion
Prevent sensitive fields from being selected:
Function-Based Configuration
Dynamic defaults and exclusions based on the current selection:
Prisma 7 — DMMF Changes
In Prisma 7, Prisma.dmmf is no longer exported. PrismaSelect uses DMMF for field validation (filtering invalid fields before they reach Prisma).
Without DMMF: PrismaSelect still works — it generates select objects but skips field validation. Invalid fields may cause Prisma runtime errors.
With generated DMMF (recommended):
This is the recommended approach for Prisma 7. The @paljs/generator captures DMMF during prisma generate and outputs it as a JSON file.
sdlInputs
Generates SDL input type definitions from Prisma DMMF. Useful for SDL-first GraphQL servers:
Performance
Without PrismaSelect
With PrismaSelect
Framework Examples
Apollo Server
GraphQL Yoga
Production Best Practices
1. Always Use Authorization
PrismaSelect optimizes queries but doesn't handle authorization. Always check permissions:
2. Validate Input
Don't pass user input directly to Prisma:
3. Exclude Sensitive Fields
Use excludeFields to prevent sensitive data from being exposed: