Hello Prisma User!

This guide is for you if you use @prisma/client on a project that does not use Nexus but are wondering if you should.

Nexus is a feature rich GraphQL Framework. One of its hallmark features is how it helps you achieve a very high degree of type-safety as you implement your API. If you are a long-time Prisma user you can see it as a spiritual successor to the rich GraphQL experiences that Prisma 1 and even Graphcool offered. Nexus is still young, but growing fast.

If you haven't already, you should read the Welcome to Nexus introduction.

This guide will show you the ways you can use Nexus with the Prisma toolkit.

Vanilla integration

As a Prisma user you can easily integrate Prisma into Nexus yourself, take a look:

1import { PrismaClient } from '@prisma/client'
2import { schema } from 'nexus'
4const db = new PrismaClient()
6schema.addToContext(({ req, res }) => ({ db })) // expose Prisma Client to all resolvers
9 definition(t) {
10 t.field('...', {
11 type: '...'
12 resolve(_, __, ctx) {
13 ctx.db // <- Prisma Client
14 }
15 })
16 }

Run nexus dev in one shell, and your usual prisma workflow in another. ✅


This is fine, but there's something better. The Nexus Prisma plugin (nexus-plugin-prisma). It levels up your experience, including:

  • Bundling the Prisma deps
  • Running your Prisma generators
  • Integrating your Prisma Client automatically, including into Nexus' test system
  • Declarative APIs for projecting types from your Prisma schema onto your GraphQL Schema
  • Declarative APIs for creating mutations and queries (including automatically implemented resolvers!)

If you haven't already, you should read the Welcome to Nexus Prisma introduction.

Learning Path

  1. Read Welcome to Nexus
  2. Do The Nexus Tutorial
  3. If using the Prisma plugin (you should!) read Welcome to Nexus Prisma


$npm add nexus nexus-plugin-prisma
$npm run nexus
Edit this page on Github