Skip to content

v0.4.1

Compare
Choose a tag to compare
@jasonkuhrt jasonkuhrt released this 26 Sep 03:40
· 274 commits to master since this release

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.

  1. Remove generator nexus_prisma from your schema.prisma:

    - generator nexus_prisma {
    -   provider = "nexus-prisma"
    - }
  2. Install nexus-prisma

    npm install nexus-prisma
    
  3. 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.

  1. makePrismaSchema

    nexus-prisma is now a nexus plugin. It means we no longer use makePrismaSchema 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 })],
      })
  2. prismaObjectType

    This function no longer exists. Instead, use objectType from nexus.

    t.prismaFields(...) was removed in favor of two new properties: t.model & t.crud.

    NOTE: t.prismaFields(['*']) has no equivalent anymore. See #299

    For the Query & Mutation types

    t.crud is available only on the Query and Mutation type. It replaces t.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 replaces t.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()
        }
    })
  3. prismaInputObjectType

    This function no longer exists and don't have equivalent yet. See #477

  4. prismaExtendType

    This function no longer exists and don't have equivalent yet.

  5. t.prismaType

    This property no longer exists and don't have equivalent yet. See #303