Prisma-binding produces incorrect types for nullable update mutations

prisma

#1

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.

ctx.db.mutation.updateCompany({
    where: { slug: "myCompany" },
    data: { vatNumber: null }
}, info);

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:

export interface CompanyUpdateInput {
  slug?: String
  name?: String
  vatNumber?: String
  businessId?: String
}

The nullable fields (vatNumber & businessId) should have the union type String | null, so I can null them if I wish.

Is this a bug in Prisma-binding or am I doing something completely wrong? I have updated to version 2. Prisma 1.9

Best,
Frank


#2

Hey Frank, thanks for bringing this up.

Indeed, this seems unintended. However, I think it should be type string | null | undefined - undefined in the case it is not part of the input, and null if it’s explicitely set to null :slight_smile:

Can you create a bug report and/or PR here https://github.com/prismagraphql/prisma-binding? :raised_hands:

– Nilan


#3

Sure thing! I’ll create a report