v0.4.1
Features
- add support for Prisma 2
BREAKING CHANGES:
- Support for Prisma 1 has been dropped.
See the announcement here. For now please refer to the examples folder for how an app with nexus-prisma now looks. A migration guide will be coming soon.
Migrating From 0.4 Pre-Releases
Pre-releases of 0.4 were a Prisma generator. Here's how to migrate from that.
-
Remove
generator nexus_prismafrom yourschema.prisma:- generator nexus_prisma { - provider = "nexus-prisma" - }
-
Install nexus-prisma
npm install nexus-prisma -
Update how you import nexus-prisma:
- const { nexusPrismaPlugin } = require('@generated/nexus-prisma') + const { nexusPrismaPlugin } = require('nexus-prisma')
- import { nexusPrismaPlugin } from '@generated/nexus-prisma' + import { nexusPrismaPlugin } from 'nexus-prisma'
Migrating from 0.3.x
nexus-prisma@0.4.x now uses Prisma 2. Learn more about how to setup Prisma 2 here
NOTE:
⚠️ nexus-prisma@0.4.xis still in preview and might break at any moment. We advise not to upgrade yet if you're running in production.
-
makePrismaSchemanexus-prismais now a nexus plugin. It means we no longer usemakePrismaSchemabut Nexus'makeSchemafunction instead.- import { makePrismaSchema } from 'nexus-prisma' + import { nexusPrismaPlugin } from 'nexus-prisma' + import { makeSchema } from 'nexus' import * as types from './graphql' - const schema = makePrismaSchema({ + const schema = makeSchema({ - types + types: [types, nexusPrismaPlugin({ types })], })
-
prismaObjectTypeThis function no longer exists. Instead, use
objectTypefromnexus.t.prismaFields(...)was removed in favor of two new properties:t.model&t.crud.NOTE:
t.prismaFields(['*'])has no equivalent anymore. See #299For the Query & Mutation types
t.crudis available only on theQueryandMutationtype. It replacest.prismaFields(...)- import { prismaObjectType } from 'nexus-prisma' + import { objectType } from 'nexus' - const Query = prismaObjectType({ + const Query = objectType({ name: 'Query', definition(t) { - t.prismaFields(['user', 'users']) + t.crud.user() + t.crud.users({ filtering: true, ordering: true }) } })
For types that maps to Prisma model
t.modelbecomes available. It replacest.prismaFields(...).NOTE: You can now have object types that have different names that your prisma models. If that's the case, use
t.model('<PrismaModelName>').someField().- import { prismaObjectType } from 'nexus-prisma' + import { objectType } from 'nexus' - const User = prismaObjectType({ + const User = objectType({ name: 'User', definition(t) { - t.prismaFields(['id', 'name', 'age']) + t.model.id() + t.model.name() + t.model.age() } })
-
prismaInputObjectTypeThis function no longer exists and don't have equivalent yet. See #477
-
prismaExtendTypeThis function no longer exists and don't have equivalent yet.
-
t.prismaTypeThis property no longer exists and don't have equivalent yet. See #303