-
-
Couldn't load subscription status.
- Fork 126
Description
@ymc9 I've updated to 2.9.1 which includes your PR #1842, and I am seeing failing mutations, and no network requests being made, when optimisticUpdate: true.
The cases that are failing include optional "belongs-to" relationships where no relationship has yet been formed. For example:
model SomeModel {
id String @id @default(uuid())
title String
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade)
businessId String?
}
I am seeing this error:
Error - there was an error updating SomeModel TypeError: Cannot convert undefined or null to object
The error is about to the "business" relationship from the above schema, and an evaluation on this line from mutator.ts:
| for (const [key, value] of Object.entries(resultData)) { |
Because no business has been related to SomeModel the value of both business and businessId is null. Your change expects either an array or an object.
If I set optimisticUpdates: false for the mutation the error goes away and mutations are successful.
Should L165 be doing a null check?