Skip to content

Commit

Permalink
feat: upgrade prisma to 2.19.0 (#130)
Browse files Browse the repository at this point in the history
* upgrade prisma to 2.19.0
  • Loading branch information
Jenn authored Apr 2, 2021
1 parent 4c482ba commit ebc68d9
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 567 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ to: graphql/modules/<%= name %>.ts
---
<% camelized = h.inflection.camelize(name) -%>
<% plural = h.inflection.pluralize(camelized) -%>
import { objectType, extendType } from '@nexus/schema';
import { objectType, extendType } from 'nexus';
import { UserInputError, /*ForbiddenError*/ } from 'apollo-server-micro';

// import { isAdmin } from '../services/permissions';
Expand Down
2 changes: 1 addition & 1 deletion packages/create-bison-app/template/graphql/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { objectType } from '@nexus/schema';
import { objectType } from 'nexus';

// Profile Type
export const Profile = objectType({
Expand Down
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');
10 changes: 5 additions & 5 deletions packages/create-bison-app/template/graphql/modules/user.ts.ejs
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';
Expand Down Expand Up @@ -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}`, {
Expand Down Expand Up @@ -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.', {
Expand All @@ -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.', {
Expand Down Expand Up @@ -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' });
},
});
12 changes: 6 additions & 6 deletions packages/create-bison-app/template/graphql/schema.ts
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';
Expand All @@ -13,6 +13,7 @@ export const schema = makeSchema({
types,
plugins: [
fieldAuthorizePlugin(),
declarativeWrappingPlugin(),
nexusPrisma({
experimentalCRUD: true,
outputs: {
Expand All @@ -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'),
alias: 'ContextModule',
},
],
contextType: 'ContextModule.Context',
},
prettierConfig,
});
29 changes: 15 additions & 14 deletions packages/create-bison-app/template/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"db:reset": "yarn prisma migrate reset && yarn build:prisma",
"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\"",
Expand All @@ -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",
"g:test:component": "hygen test component --name",
"g:test:factory": "hygen test factory --name",
"g:test:request": "hygen test request --name",
Expand All @@ -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",
<% } -%>
Expand All @@ -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",
"@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",
Expand All @@ -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"
},
"bison": {
"version": "<%= bisonVersion %>",
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit ebc68d9

Please sign in to comment.