-
Notifications
You must be signed in to change notification settings - Fork 126
Description
Describe the Bug
I'm trying to use an upsert operation and getting a error that doesn't seem to match what I'd expect on the update side. The error says that I need to specify "one of 'id'" property (which I'm not even sure how to acquire for the given object at this time without submitting another query to the database, but I will if I have to), but there is no 'id' field, either on the generated GraphQL schema or on the generated TypeGraphQL Input class. I have seen a similar error before, but it was legitimate and told me how there were multiple fields, and I was genuinely missing one that was needed. So this behavior is odd in three ways:
- It seems strange that the error message for multiple fields would be used for a case where a single field is required. This leads me to believe that something weird happened.
- Nowhere in the generated code can I even find the definition for the field it's looking for
- It is pretty rare in typegraphql-prisma to require an ID on a query/where. In fact, I've been surprised sometimes when I'm not even able to provide an ID when I want to. I often have to create a where clause to find the object I want to connect to the object being created. The only case where I've seen it requiring an ID is when I have a multi-field unique constraint that includes an ID. It just seems odd that in this specific case it would require an ID.
These things together lead me to believe that this is indeed a bug.
Note that this is occurring when I'm essentially trying to link two models together through a third model. In my case, it's Tags, Locations, and TagToObjectRelations. The tag field has a multi-field unique constraint for its userId and name.
To Reproduce
I don't have time right at the moment or really until next week, but I will try to make a minimal reproduction repo. For now, the relevant repo is https://github.com/t-rad679/egrim
Here are some relevant pieces of code:
CreateOrUpdateLocationForm.vuein that reposrc/server/prisma/schema.prismain that repo- Generated TagToObjectRelationWhereUniqueInput.ts
- TagToObjectRelationWhereInput in generated-schema.graphql
Expected Behavior
- The field the error message is telling me to include exists on the generated GraphQL schema and, ideally, the generated TypeGraphQL Input class.
- I can achieve what I'm trying to achieve with a uniquely identifying where clause instead of an ID
Logs
stack trace
Environment (please complete the following information):
- OS: Arch Linux
- Node: 22.8.0
typegraphql-prismaversion: 0.27.2- Prisma version 5.11.0
- TypeScript version: 5.1.3
Additional Context
Add any other context about the problem here.