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_prisma
from 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.x
is still in preview and might break at any moment. We advise not to upgrade yet if you're running in production.
-
makePrismaSchema
nexus-prisma
is now a nexus plugin. It means we no longer usemakePrismaSchema
but Nexus'makeSchema
function 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 })], })
-
prismaObjectType
This function no longer exists. Instead, use
objectType
fromnexus
.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.crud
is available only on theQuery
andMutation
type. 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.model
becomes 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() } })
-
prismaInputObjectType
This function no longer exists and don't have equivalent yet. See #477
-
prismaExtendType
This function no longer exists and don't have equivalent yet.
-
t.prismaType
This property no longer exists and don't have equivalent yet. See #303