-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: upgrade prisma to 2.19.0 #130
Changes from all commits
29df413
9ddb6f2
ac5fb02
7f967ba
3eb1234
ae2380f
6d9d2fa
d4f917c
6c12f50
ad27615
d864ce9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ export async function createContext(context: ApolloApiContext): Promise<Context> | |
let user: User | null = null; | ||
|
||
if (authHeader) { | ||
user = await prisma.user.findOne({ where: { id: authHeader.userId } }); | ||
user = await prisma.user.findUnique({ where: { id: authHeader.userId } }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a syntax change with the newest Prisma There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 had to do this recently in the CITJS repo as well |
||
} | ||
|
||
return { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { DateTimeResolver, JSONObjectResolver } from 'graphql-scalars'; | ||
import { asNexusMethod } from '@nexus/schema'; | ||
import { asNexusMethod } from 'nexus'; | ||
|
||
export const jsonScalar = asNexusMethod(JSONObjectResolver, 'json'); | ||
export const dateTimeScalar = asNexusMethod(DateTimeResolver, 'date'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { objectType, extendType, inputObjectType, stringArg, arg } from '@nexus/schema'; | ||
import { objectType, extendType, inputObjectType, stringArg, arg } from 'nexus'; | ||
import { Role } from '@prisma/client'; | ||
<% if (host.name === 'vercel') { -%> | ||
import { UserInputError, ForbiddenError } from 'apollo-server-micro'; | ||
|
@@ -84,7 +84,7 @@ export const Mutations = extendType({ | |
}, | ||
resolve: async (_root, args, ctx) => { | ||
const { email, password } = args; | ||
const user = await ctx.db.user.findOne({ where: { email } }); | ||
const user = await ctx.db.user.findUnique({ where: { email } }); | ||
|
||
if (!user) { | ||
throw new UserInputError(`No user found for email: ${email}`, { | ||
|
@@ -117,7 +117,7 @@ export const Mutations = extendType({ | |
throw new ForbiddenError('Not authorized'); | ||
} | ||
|
||
const user = await ctx.db.user.findOne({ where: { email: args.data.email } }); | ||
const user = await ctx.db.user.findUnique({ where: { email: args.data.email } }); | ||
|
||
if (user) { | ||
throw new UserInputError('Email already exists.', { | ||
|
@@ -144,7 +144,7 @@ export const Mutations = extendType({ | |
data: arg({ type: 'SignupInput', required: true }), | ||
}, | ||
resolve: async (_root, args, ctx) => { | ||
const existingUser = await ctx.db.user.findOne({ where: { email: args.data.email } }); | ||
const existingUser = await ctx.db.user.findUnique({ where: { email: args.data.email } }); | ||
|
||
if (existingUser) { | ||
throw new UserInputError('Email already exists.', { | ||
|
@@ -178,6 +178,6 @@ export const SignupInput = inputObjectType({ | |
definition: (t) => { | ||
t.string('email', { required: true }); | ||
t.string('password', { required: true }); | ||
t.field('profile', { type: 'ProfileCreateOneWithoutUserInput' }); | ||
t.field('profile', { type: 'ProfileCreateNestedOneWithoutUserInput' }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another syntax change with latest Prisma, discovered through build error and tracking down type generations |
||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import path from 'path'; | ||
|
||
import { fieldAuthorizePlugin, makeSchema } from '@nexus/schema'; | ||
import { declarativeWrappingPlugin, fieldAuthorizePlugin, makeSchema } from 'nexus'; | ||
import { nexusPrisma } from 'nexus-plugin-prisma'; | ||
|
||
import prettierConfig from '../prettier.config'; | ||
|
@@ -13,6 +13,7 @@ export const schema = makeSchema({ | |
types, | ||
plugins: [ | ||
fieldAuthorizePlugin(), | ||
declarativeWrappingPlugin(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was required to add to the configuration in order to satisfy some of the current schema definitions we had. |
||
nexusPrisma({ | ||
experimentalCRUD: true, | ||
outputs: { | ||
|
@@ -27,18 +28,17 @@ export const schema = makeSchema({ | |
schema: path.join(currentDirectory, 'api.graphql'), | ||
typegen: path.join(currentDirectory, 'node_modules/@types/nexus-typegen/index.d.ts'), | ||
}, | ||
typegenAutoConfig: { | ||
sources: [ | ||
sourceTypes: { | ||
modules: [ | ||
{ | ||
source: path.join(currentDirectory, 'node_modules/.prisma/client/index.d.ts'), | ||
module: path.join(currentDirectory, 'node_modules/.prisma/client/index.d.ts'), | ||
alias: 'db', | ||
}, | ||
{ | ||
source: path.join(currentDirectory, 'graphql', 'context.ts'), | ||
module: path.join(currentDirectory, 'graphql', 'context.ts'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the updated config Syntax, not documented well for the migration |
||
alias: 'ContextModule', | ||
}, | ||
], | ||
contextType: 'ContextModule.Context', | ||
}, | ||
prettierConfig, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,15 @@ | |
"cacheDirectories": [".next/cache"], | ||
<% } -%> | ||
"scripts": { | ||
"build": "ts-node ./scripts/buildProd", | ||
"build": "ts-node -P tsconfig.cjs.json ./scripts/buildProd", | ||
"build:prisma": "prisma generate", | ||
"build:next": "next build", | ||
"build:nexus": "NODE_ENV=development ts-node -P tsconfig.cjs.json --transpile-only graphql/schema.ts", | ||
"cypress:open": "cypress open", | ||
"cypress:run": "cypress run", | ||
"db:migrate": "yarn -s prisma migrate up --experimental && yarn build:prisma", | ||
"db:rollback": "yarn prisma migrate down --experimental && yarn build:prisma", | ||
"db:migrate": "yarn -s prisma migrate dev && yarn build:prisma", | ||
"db:deploy": "yarn -s primsa deploy && yarn build:prisma", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prisma no longer uses the |
||
"db:reset": "yarn prisma migrate reset && yarn build:prisma", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prisma no longer offers a direct rollback feature or |
||
"db:setup": "yarn db:migrate && yarn prisma generate", | ||
"db:drop": "DOTENV_CONFIG_PATH=./prisma/.env ts-node -r dotenv/config ./scripts/dropDatabase", | ||
"dev": "concurrently -n \"WATCHERS,NEXT\" -c \"black.bgYellow.dim,black.bgCyan.dim\" \"yarn watch:all\" \"next dev\"", | ||
|
@@ -22,7 +23,7 @@ | |
"g:component": "hygen component new --name", | ||
"g:graphql": "hygen graphql new --name", | ||
"g:page": "hygen page new --name", | ||
"g:migration": "yarn -s prisma migrate save --experimental", | ||
"g:migration": "yarn -s prisma migrate dev", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated syntax for prisma 2.19.0 |
||
"g:test:component": "hygen test component --name", | ||
"g:test:factory": "hygen test factory --name", | ||
"g:test:request": "hygen test request --name", | ||
|
@@ -44,8 +45,7 @@ | |
"@apollo/client": "^3.0.2", | ||
"@chakra-ui/react": "1.3.4", | ||
"@chakra-ui/theme": "1.7.1", | ||
"@nexus/schema": "^0.16.0", | ||
"@prisma/client": "2.8.1", | ||
"@prisma/client": "^2.19.0", | ||
<% if (host.name === 'vercel') { -%> | ||
"apollo-server-micro": "^2.18.1", | ||
<% } -%> | ||
|
@@ -62,28 +62,28 @@ | |
"graphql-type-json": "^0.3.1", | ||
"jsonwebtoken": "^8.5.1", | ||
"next": "9.5.3", | ||
"nexus-plugin-prisma": "^0.21.0", | ||
"nexus": "^1.0.0", | ||
"nexus-plugin-prisma": "^0.33.0", | ||
"react": "16.13.1", | ||
"react-dom": "16.13.1", | ||
"react-hook-form": "^6.1.0", | ||
"universal-cookie": "^4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@apollo/react-testing": "^4.0.0", | ||
"@graphql-codegen/cli": "1.17.6", | ||
"@graphql-codegen/typescript": "1.17.6", | ||
"@graphql-codegen/cli": "^1.21.3", | ||
"@graphql-codegen/typescript": "^1.17.6", | ||
"@graphql-codegen/typescript-operations": "^1.17.6", | ||
"@graphql-codegen/typescript-react-apollo": "1.17.6", | ||
"@graphql-codegen/typescript-resolvers": "1.17.4", | ||
"@prisma/cli": "2.8.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏 |
||
"@graphql-codegen/typescript-react-apollo": "^1.17.6", | ||
"@graphql-codegen/typescript-resolvers": "^1.17.4", | ||
"@testing-library/cypress": "^7.0.2", | ||
"@testing-library/dom": "^7.21.7", | ||
"@testing-library/jest-dom": "^5.11.2", | ||
"@testing-library/react": "^10.4.7", | ||
"@testing-library/user-event": "^12.0.17", | ||
"@types/bcryptjs": "^2.4.2", | ||
"@types/jest": "^26.0.6", | ||
"@types/node": "^14.0.26", | ||
"@types/node": "^14.14.21", | ||
"@types/react": "^16.9.43", | ||
"@types/supertest": "^2.0.10", | ||
"@vercel/node": "^1.7.3", | ||
|
@@ -104,11 +104,12 @@ | |
"nanoid": "^3.1.10", | ||
"pg": "^8.3.0", | ||
"prettier": "^2.0.5", | ||
"prisma": "^2.19.0", | ||
"start-server-and-test": "^1.11.2", | ||
"supertest": "^4.0.2", | ||
"ts-jest": "^26.1.3", | ||
"ts-node-dev": "^1.0.0", | ||
"typescript": "^3.9.7" | ||
"typescript": "^4.1.3" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to match peer dependencies. |
||
}, | ||
"bison": { | ||
"version": "<%= bisonVersion %>", | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Library
@nexus/schema
was deprecated and moved tonexus