Julien Goux
03/17/2021, 10:13 AMJulien Goux
03/17/2021, 10:14 AMJulien Goux
03/17/2021, 10:19 AMjasonkuhrt
Julien Goux
03/22/2021, 1:49 PMJulien Goux
03/22/2021, 1:50 PMJulien Goux
03/22/2021, 1:50 PMJulien Goux
03/22/2021, 1:50 PMJulien Goux
03/22/2021, 1:50 PMDregond
03/23/2021, 5:26 AMDregond
03/23/2021, 5:26 AMexport const UserWithCount = objectType({
nonNullDefaults: {
output: true,
input: false,
},
name: 'UserWithCount',
definition(t) {
t.int('findManyUserCount')
t.list.field('findManyUser', {
type: 'User',
})
},
})
Dregond
03/23/2021, 5:27 AMimport { queryField, nonNull, list } from 'nexus'
export const UserFindManyWithCountQuery = queryField('findManyUserWithCount', {
type: nonNull('UserWithCount'),
args: {
where: 'UserWhereInput',
orderBy: list('UserOrderByInput'),
cursor: 'UserWhereUniqueInput',
distinct: 'UserScalarFieldEnum',
skip: 'Int',
take: 'Int',
},
resolve(_parent, args, { prisma, select }) {
return {
findManyUserCount: prisma.user.count({
where: args.where,
}),
findManyUser: prisma.user.findMany({
...args,
...select.findManyUser,
}),
}
},
})
Dregond
03/23/2021, 5:37 AM$ yarn tsc
yarn run v1.22.5
$ D:\Work\NodeJS\warehouse\backend\node_modules\.bin\tsc
src/graphql/User/queries/findWithCount.ts:13:3 - error TS2322: Type '(_parent: {}, args: { cursor?: { email?: string; id?: number; }; distinct?: "id" | "name" | "createdAt" | "email" | "password"; orderBy?: { createdAt?: "asc" | "desc"; email?: "asc" | "desc"; id?: "asc" | "desc"; name?: "asc" | "desc"; password?: "asc" | "desc";
}[]; skip?: number; take?: number; where?: { ...; }; }...' is not assignable to type 'FieldResolver<"Query", "findManyUserWithCount">'.
Type '{ findManyUserCount: PrismaPromise<number>; findManyUser: PrismaPromise<User[]>; }' is not assignable to type 'MaybePromise<{ findManyUser: { createdAt: any;
email: string; id: number; name?: string; password: string; }[]; findManyUserCount: number; }>'.
Type '{ findManyUserCount: PrismaPromise<number>; findManyUser: PrismaPromise<User[]>; }' is not assignable to type '{ findManyUser: { createdAt: any; email: string; id: number; name?: string; password: string; }[]; findManyUserCount: number; }'.
Types of property 'findManyUser' are incompatible.
Type 'Promise<User[]> & { [prisma]: true; }' is missing the following properties from type '{ createdAt: any; email: string; id: number; name?: string; password: string; }[]': length, pop, push, concat, and 28 more.
13 resolve(_parent, args, { prisma, select }) {
Robert Witchell
03/28/2021, 3:05 AMJulien Goux
03/30/2021, 8:35 AMJulien Goux
03/30/2021, 8:36 AMJulien Goux
03/30/2021, 8:37 AMJulien Goux
03/30/2021, 8:37 AMJulien Goux
03/30/2021, 8:38 AMJulien Goux
03/30/2021, 7:58 PMDregond
03/31/2021, 8:25 AMsven
03/31/2021, 12:00 PMAkshay Kadam (A2K)
03/31/2021, 1:03 PM➜ npm add nexus-plugin-prisma @prisma/client
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: node-graphql@1.0.0
npm ERR! Found: @prisma/client@2.20.1
npm ERR! node_modules/@prisma/client
npm ERR! @prisma/client@"2.20.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @prisma/client@"2.19.x" from nexus-plugin-prisma@0.33.0
npm ERR! node_modules/nexus-plugin-prisma
npm ERR! nexus-plugin-prisma@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I had the above error. I fixed it with --legacy-peer-deps
but then I run my app, I get the following error:
TypeError: debugLib is not a function
at Object.<anonymous> (~/server/node_modules/.prisma/client/index.js:21:15)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Module._compile (~/server/node_modules/source-map-support/source-map-support.js:547:25)
at Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Object.nodeDevHook [as .js] (~/server/node_modules/ts-node-dev/lib/hook.js:63:13)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:997:19)
are my package.json
versions okay?
"dependencies": {
"@prisma/client": "^2.20.1",
"apollo-server": "^2.22.2",
"graphql": "^15.5.0",
"graphql-scalars": "^1.9.0",
"nexus": "^1.0.0",
"nexus-plugin-prisma": "^0.33.0"
},
"devDependencies": {
"nodemon": "^2.0.7",
"prisma": "2.20.1",
"rimraf": "^3.0.2",
"ts-node-dev": "^1.1.6",
"typescript": "^4.2.3"
}
Akshay Kadam (A2K)
03/31/2021, 1:36 PMimport { queryType } from 'nexus'
export const Query = queryType({
definition(t) {
t.crud.blogs()
<http://t.crud.blog|t.crud.blog>({
alias: 'blog',
})
t.nonNull.field('totalSum', {
type: 'Int',
resolve: (_root, _args, ctx) => {
console.log('totalSum', ctx)
const totalSum = ctx.prisma.blog.aggregate({
sum: {
price: true,
},
})
return totalSum
},
})
},
})
Akshay Kadam (A2K)
03/31/2021, 1:36 PMctx.prisma
comes undefined
Akshay Kadam (A2K)
03/31/2021, 1:37 PMctx.db
but that was undefined
as well (i think ctx.db
api was 6 months back)Akshay Kadam (A2K)
03/31/2021, 1:37 PMctx.
Yash Gupta
04/01/2021, 5:01 AMYash Gupta
04/01/2021, 5:03 AMYash Gupta
04/01/2021, 5:16 AM