Releases: graphql-nexus/nexus-plugin-prisma
v0.5.0
Features
- abe6c9c feat: turn into nexus plugin (#434)
- 3921aa5 feat(typegen): NEXUS_SHOULD_GENERATE_ARTIFACTS env var (#456)
- b44d644 feat(typegen): pretty @types package name
Fixes
- d59b9e8 fix: publish scalars from input types (#487)
- 63277cc fix: only publish non-null list + list members (#452)
- 758da5b fix: publish object types that don't map to prisma models… (#451)
- 6551222 fix(publishing): publish dmmf objects (#441)
- d7d59d8 fix(typegen): enum-field publishing on models (#443)
- 827ec4e fix(deps): make @prisma/photon a prod dep
- ec1d848 fix(typegen): delete prev file before writing next (#454)
Other
- 7460d1b docs: intro, concepts, reference (#459)
- b008c71 docs: show gql null args flowing into photon
BREAKING CHANGES:
-
You will need
nexus@0.12.0-beta.14
-
ca22bb0 fix: generated publishers are now all camel-cased (#481)
import { objectType } from 'nexus-prisma' const Query = objectType({ name: 'Query', definition(t) { - t.modelnames() - t.modelname() + t.modelName() + t.modelNames() } })
-
You now use nexus-prisma as a nexus plugin
import { nexusPrismaPlugin } from 'nexus-prisma import { makeSchema } from 'nexus' import * as types from './types' makeSchema({ - types: [types, nexusPrismaPlugin({ types })], + types, + plugins: [nexusPrismaPlugin()] })
-
export
NexusPrismaParams
renamed toOptions
v0.4.2
Fixes
- An issue where
tsc
build would fail withoutskipLibCheck
present is resolved.
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
v0.3.7
- Add better support for subscriptions.
- Rollback nexus-prisma-generate: --output option needs to be inputted from the root path of the project again instead of relatively
WARNING:
Susbcriptions are still not supported through t.prismaFields()
. They are however better supported with nexus + the prisma-client without having to do the following: graphql-nexus/nexus#86 (comment)
Guide
Given the following datamodel:
type User {
id: ID! @id
name: String!
}
- Use the nexus'
subscriptionField
method.
export const UserSubscription = subscriptionField('user', {
type: 'UserSubscriptionPayload', // Use prisma's subscription type as output
subscribe(root, args, ctx) {
return ctx.prisma.$subscribe.user() as any // Cast to any because of typings mismatch
},
resolve(payload) {
return payload
},
})
UserSubscriptionPayload
is Prisma's graphql output type for subscriptions. For aPost
type, it would have beenPostSubscriptionPayload
.
This is what the type actually looks like:
type UserSubscriptionPayload {
mutation: MutationType!
node: User
previousValues: UserPreviousValues
updatedFields: [String!]
}
type UserPreviousValues {
createdAt: DateTime!
email: String!
gender: GENDER!
id: ID!
name: String
updatedAt: DateTime!
}
enum MutationType {
CREATED
DELETED
UPDATED
}
Because nexus-prisma automatically look for missing types in Prisma's GraphQL schema, all these types will magically be imported for you under the hood by simply referencing UserSubscriptionPayload
.
-
There's currently still a mismatch between prisma's typings and nexus' ones. For now, please cast
prisma.$subscribe.user()
toany
. graphql-nexus/nexus#120 should be merged soon and will fix that problem -
Don't forget to export
export const Something = subscriptionField
intomakePrismaSchema.types
property -
Enjoy 🙏
v0.3.6
nexus-prisma
- Fixed enums fetched twice (9fd481e)
nexus-prisma-generate
- BREAKING: Consolidated file paths with the prisma-client. You should now use relative path for the
--output
option (instead of relative to the root of project as before) - Add
--project
option to point to a prisma.yml file in cases where we cannot find it automatically
v0.3.5
v0.3.4
- (BREAKING) Fixes bug with embedded types (when using mongo)
- This required adding an
embeddedTypes
property to the generateddatamodelInfo
- This required adding an
- (BREAKING): Remove
Query.node
field from generated API (and from the typings) - Fixes
nexus-prisma-generate
wrongly resolvingprisma-client
path when omitting--client option
Please, re-run nexus-prisma-generate to fix the breaking changes