BRob
04/28/2021, 11:25 PMAdam
05/03/2021, 2:35 PMnexus-plugin-prisma
(we held out seeing if the new functionality would be ready by Q2) How should the SortOrder
be defined? I'm following the guide here (https://nexusjs.org/docs/plugins/prisma/removing-the-nexus-plugin-prisma) but the docs don't seem to be correct. For example if you follow it and do
const SortOrder = enumType({
name: 'SortOrder',
members: ['asc', 'desc'],
})
const PostOrderByInput = inputObjectType({
name: 'PostOrderByInput',
definition(t) {
t.field('title', {
type: 'SortOrder',
})
},
})
const User = objectType({
name: 'User',
definition(t) {
<http://t.nonNull.int|t.nonNull.int>('id')
t.string('name')
t.nonNull.list.nonNull.field('posts', {
type: 'Post',
args: {
cursor: arg({ type: 'PostWhereUniqueInput' }),
take: intArg(),
skip: intArg(),
orderBy: arg({ type: 'PostOrderByInput' }),
where: arg({ type: 'PostWhereInput' }),
},
resolve: (parent, args, context) => {
return context.prisma.user
.findUnique({
where: { id: parent.id },
})
.posts({
cursor: args.cursor || undefined,
take: args.take || undefined,
skip: args.skip || undefined,
orderBy: args.orderBy || undefined,
where: {
id: args.where?.id || undefined,
title: args.where?.title || undefined
},
})
},
})
},
})
It gives you an error because `prisma`'s orderBy
cannot take null | undefined fields, and the orderByInput is optional for each field of the object
Types of property 'id' are incompatible.
Type 'SortOrder | null | undefined' is not assignable to type 'SortOrder | undefined'.
Type 'null' is not assignable to type 'SortOrder | undefined'.ts(2322)
Is there a more concise way of typing this rather than making a new object with explicitly non-null fields?Robert Witchell
05/04/2021, 10:47 AMt.nonNull.field('createUserViaUserDetail', {
type: 'UserDetail',
args: arg({
type: 'UserDetailUncheckedCreateInput',
}),
resolve: async (parent, { data }, { prisma, userId }, info) => {
return prisma.userDetail.create({ data })
},
})
[ERROR]:
- Missing type undefined, did you forget to import a type to the root query?
- Missing type UserDetailUncheckedCreateInput, did you forget to import a type to the root
Akshay Kadam (A2K)
05/06/2021, 1:26 PMnonNull
in args
in nexus
, does it mean that the input is required? Or it's just not equal to null
?
export const Query = queryType({
definition(t) {
t.nonNull.list.field('getAcquisitionsByPrice', {
type: 'Acquisition',
args: {
minPrice: nonNull(arg({ type: 'BigInt' })),
maxPrice: nonNull(arg({ type: 'BigInt' })),
},
Also, how do I set a field to be optional in nexus
args?Milan
05/08/2021, 4:55 AMMilan
05/08/2021, 4:56 AMPhilipp Humburg
05/18/2021, 9:08 PMDaniel Esteves
05/22/2021, 11:19 PMuser
and userId
fields from that inputPhilipp Humburg
05/24/2021, 8:34 PMТоше
05/26/2021, 7:37 AMexport const UsersAvgAge = extendType({
type: 'User',
definition(t) {
t.field('aggregate', {
type: 'AggregateUser',
resolve(_parent, args, { prisma }, info) {
const select = new PrismaSelect(info).value
return prisma?.useDetail?.aggregate({
where: { id: { equals: _parent.id } },
...select,
})
},
})
},
})
Kevin Serrano
05/27/2021, 6:59 AMTSError: ⨯ Unable to compile TypeScript:
src/modules/ProjectOwner.ts:11:7 - error TS2339: Property 'dateTime' does not exist on type 'ObjectDefinitionBlock<"ProjectOwner">'.
11 t.dateTime(PO.createdAt.name, PO.createdAt)
The makeSchema looks like this:
import NexusPrismaScalars from 'nexus-prisma/scalars'
import { makeSchema } from 'nexus'
import * as types from './modules/types'
export const schema = applyMiddleware(
makeSchema({
types: {
...types,
...NexusPrismaScalars
},
...
Marcus
05/27/2021, 12:44 PM@prisma/binding-argument-transform
but I need to generate other input types. Instead of IntFilter, StringFilter,... I need field_startsWith, field_contains,... (primsa1 API)
Doing it by hand works, but the project is too big to do it at all places. I could find the right spot in the plugin source code to handle the other input filter.
Does anyone know how to do this? All ideas are welcome.Kevin Serrano
05/28/2021, 1:39 AMctx.db
for my Prisma Client. With just the data
property on the select, the resolver works fine, but as soon as I add the select
property, typescript starts freaking out. It stops freaking out if I manually add every single property that exists on a projectOwner that's exposed on nexus.
However, it's weird because the resolver isn't even expecting a projectOwner--it's just an intermediary in order to construct tokens, which is seen in the return. Any ideas why it's freaking out like this for subsets?Mikastark
05/31/2021, 8:22 AMhttps://user-images.githubusercontent.com/23034761/120086933-db0b6b80-c0e3-11eb-9f2f-732ff9c5514c.png▾
return context.prisma.posts.findMany(args)
)David Panart
06/22/2021, 10:58 AM<https://www.kaviarjs.com/>
do ? That's an incredible featureVincent
06/22/2021, 12:45 PMType '1 | 2 | 3' is not assignable to type 'RoleCreateNestedOneWithoutUserInput | undefined'.
Type '1' is not assignable to type 'RoleCreateNestedOneWithoutUserInput | undefined'.ts(2322)
index.d.ts(2682, 5): The expected type comes from property 'role' which is declared here on type 'UserCreateInput'
(property) role?: Prisma.RoleCreateNestedOneWithoutUserInput | undefined
Thank you for your answers.divyendu
06/23/2021, 9:05 AMchrisdrackett
06/30/2021, 11:47 PMshouldExitAfterGenerateArtifacts
but it does not seem to be workingchrisdrackett
06/30/2021, 11:58 PMChristian Villamin
07/02/2021, 6:00 PMKerim Hudson
07/05/2021, 3:43 PMChristian Villamin
07/13/2021, 7:25 AMТоше
07/23/2021, 7:45 AMludovic
07/25/2021, 7:42 PMRostislav Simonik
07/29/2021, 6:24 AMconst SomeInput = inputObjectType({
name: 'SomeInput',
definition(t) {
t.nonNull.optional.string('some') /// that would autogenerate runtime validation so given value can be undefined but not null
}
})
is there any plan to do so, or existing solution how to address this without writing unnecessary boilerplate code ? thx for info.Michael
08/05/2021, 10:28 PMnext dev
webpack is installing all the code I dont need and crashing it. Anyone have any ideas on how to fix this?Michael
08/05/2021, 10:29 PM/***/ "./src/server/graphql/BranchCode/queries/index.ts":
/*!********************************************************!*\
!*** ./src/server/graphql/BranchCode/queries/index.ts ***!
\********************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
Michael
08/05/2021, 10:29 PMMichael
08/06/2021, 8:57 PMMichael
08/06/2021, 8:58 PM