Skip to content

Commit

Permalink
fix: 🐛 allow null query
Browse files Browse the repository at this point in the history
  • Loading branch information
dennemark committed Sep 19, 2024
1 parent 0e96b65 commit 119ba28
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/applyDataQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ export function applyDataQuery(
// get all mutation arg fields and if they are short code connect (userId instead of user: { connect: id }), we convert it
const queriedFields = (mutation ? Object.keys(mutation) : []).map((field) => {
const relationModelId = propertyFieldsByModel[model][field]
if (relationModelId) {
mutation[relationModelId] = { connect: { id: mutation[field] } }
delete mutation[field]
if (relationModelId && mutation[field] !== null) {
const fieldId = relationFieldsByModel[model][relationModelId].relationToFields?.[0]
if (fieldId) {
mutation[relationModelId] = { connect: { [fieldId]: mutation[field] } }
delete mutation[field]
}
return relationModelId
} else {
return field
Expand Down

0 comments on commit 119ba28

Please sign in to comment.