Relationship issue
Hey, I'm probably being super duper stupid here, but I am new to Prisma and I'm missing something.
I have the schema:
I then have a JS function that reads in a JSON object, and tries to save it to the DB (shortened for brevity):
I get the repetitive error of:
2 Replies
Skipping coffee for instant knowledge! Let's brew that AI answer now.
I can see the issue with your Prisma relationship setup. This is a common problem when working with relations in Prisma.
The error you're getting (
Unknown argument requester. Did you mean requesterId?
) occurs because you're trying to use the relation field name (requester
) directly in your create operation, but Prisma expects you to use either the foreign key field (requesterId
) or a nested write operation for the relation.
Based on the knowledge sources, there are two ways to fix this:
1. Use the foreign key field directly:
2. Or keep your nested connect syntax, but make sure to use the correct structure:
The issue is that when you set requester: null
, Prisma doesn't know how to handle this. You should either omit the field entirely when it's null or use the foreign key field directly.
Also, be careful with BigInt serialization in your logs. You're already handling this correctly with your custom JSON.stringify replacer
function, but it's worth noting that BigInt values can cause serialization errors if not handled properly, as mentioned in this GitHub issue.
š¤ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.Hey š
Can you share the full generated upsert query? What is the value of mapped?