-
Notifications
You must be signed in to change notification settings - Fork 44
Prisma-binding produces incorrect types for nullable update mutations #188
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
Comments
Or as nilan suggested String | null | undefined. I suppose either
|
I had to do: const data: any = { vatNumber: null };
ctx.db.mutation.updateCompany(
{
where: { slug: "myCompany" },
data
},
info
); |
You can also use |
Any update on fixing generated types? |
Hey 👋, I believe this issue is no longer in sync with the current version of Feel free to reopen the issue if you believe we should further discuss its content. 🙂 |
Hey @maticzav I don't see how this is out of sync. type Post {
id: ID! @unique
title: String!
body: String
} The generated types are: // ...
export interface Post extends Node {
id: ID_Output
title: String
body?: String
}
// ...
export interface PostCreateInput {
title: String
body?: String
}
// ...
export interface PostUpdateInput {
title?: String
body?: String
} No |
🎉 This issue has been resolved in version 2.2.9 🎉 The release is available on: Your semantic-release bot 📦🚀 |
For a type with a nullable field, I should be able to send a mutation to update any of the nullable fields to null.
E.g.
However this yields a typescript error “Type ‘null’ is not assignable to type ‘string | undefined’.” This is because Prisma-binding produces incorrect types for the update input:
The nullable fields (vatNumber & businessId) should have the union type String | null, so I can null them if I wish.
https://www.prisma.io/forum/t/prisma-binding-produces-incorrect-types-for-nullable-update-mutations/3771
Best,
Frank
The text was updated successfully, but these errors were encountered: