Open cyrilchapon opened 10 months ago
This used to be stricter, but some changes prisma made, made maintaining it very painful.
You could probably define your type as:
export const UserSelfCreateInput: InputObjectRef<Partial<Prisma.UserCreateInput>> =
builder.prismaCreate('User', {
name: 'UserCreateInput',
fields: () => ({
// Empty
}),
});
For a lot of create inputs, you want to mix user provided inputs with things provided in the resolver, it is rare that the user is providing all fields in their input. This does lead to some lack of type-saftey.
I am not against having the types be more accurate here, but getting this to work reliably with prisma's input types without compromising other parts of the developer experience is tricky and there are higher priority features I am working on right now, so I probably won't be able to improve this until after v4 releases
Hi !
Running through the documentation, I applied the chapter "Creating input for mutations" and found a strange behavior :
This perfectly TS compile, while
Prisma.UserCreateInput
is like this :The consequence is in the resolver, when using it like so :
And the generate GraphQL is like so :
(empty input)
Which lead to runtime errors; because the GraphQL schema is not consistent to what is passed to the resolver.
I observed the exact same behavior with any kind of more complex configuration, example :
My observation is that
prismaCreate.fields
is basically just not producing something type-checkable with a type like so :