-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty Input Type for many to many relationship join tables #19
Comments
Looks like your model does not have any updateble fields, only pks and fks 😕 BTW, you should map the table name to more readable model name 😝 |
Hi @MichalLytek , first of all, the table name are comming from an old database that're using for a legacy system in my company ;) LOL that's the data table model generated by introspection model sgp_ch_turnos_agente {
idturno Int @default(1)
idagente Int
sgp_agente sgp_agente @relation(fields: [idagente], references: [idagente])
sgp_ch_turnos sgp_ch_turnos @relation(fields: [idturno], references: [idturno])
@@id([idturno, idagente])
} Thanks in advance for your assistance |
@rossinicolas Could you also raise the issue in Prisma repo? It looks like the schema introspection should detect your case and model it as a many-to-many relation in models, without the need of |
@rossinicolas Tracked by issue on Prisma repo: prisma/prisma#4004 It has to be fixed upstream. For now you need to manually modify the generated files to fix schema errors. |
Thanks.
El El vie, 30 oct. 2020 a la(s) 10:33, Michał Lytek <
notifications@github.com> escribió:
@rossinicolas <https://github.com/rossinicolas> Tracked by issue on
Prisma repo: prisma/prisma#4004
<prisma/prisma#4004>
It has to be fixed upstream. For now you need to manually modify the
generated files to fix schema errors.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHMAEEITLOZFABYOMIB6WF3SNK6DBANCNFSM4STQTDIQ>
.
--
Nicolás Rossi
rossi.nicolas@gmail.com
|
Hello, I'm also getting this error and I understand that it's because my model doesn't have any updateable fields?
In that case wouldn't it be better and more user-friendly to omit the empty type? |
If I omit the type, then I have to propagate that change up in the input types change to exclude a field of that type, etc. So it's a too complex workaround, for now please bump issue on Prisma to get more attention: |
Hello @MichalLytek, would it be possible to rename this issue to something like "Many to many relationship: join tables causes empty input type" or something like that? it would be easier to spot and we would avoid duplicating the bug 😄 |
As a workaround I solved this by adding this to my schema
not a solution, but workaround to skip the error |
Is there any updates on? |
@ZobairQ No, the Prisma issue is still open: |
Hey @MichalLytek, any updates on this? The prisma issue is closed. I also get these errors with e.g. the following model: model TemplateResource {
templateVerId Int
resourceId Int
templateVersion TemplateVersion @relation(fields: [templateVerId], references: [id])
resource Resource @relation(fields: [resourceId], references: [id])
@@id([templateVerId, resourceId])
} Error: |
Any update? I am still getting errors related to this issue |
@MichalLytek sir, any updates on the issue or any work around for this, cause we're still getting the error in my case it's saying the field is undefined |
This issue was quite a roadblock for a project at my job. We have this database that contains a few join tables with no additional fields, causing the After all, if you go deep enough down the rabbit hole, you'll see that it's all caused by an (arguably arbitrary and artificial) constraint in the GraphQL specification. There was interest in changing the spec (graphql/graphql-spec#606) but, for some reason, it all died out in the end. The current state is that some GraphQL implementations do force input object types to have at a field, and others simply don't care. Among those that do follow the spec more closely, https://github.com/graphql/graphql-js is the one causing the issue here. Going back to the workaround, I've forked a new Because this is a very quick n' dirty solution, I'm not 100% sure that it deserves a PR. But it's also true that join tables are an essential component of relational databases and one shouldn't encounter an issue such as this to begin with. @MichalLytek What do you think? |
Also, I think the "blocked" label should be removed now, as the Prisma issue that was marked as the culprit is now closed. |
This is a serious blocker in a project I work on. Solutions like
My coworker found that setting
@MichalLytek any thoughts on this solution? |
I guess we should focus on a solution which removes the empty input type (and related mutations?) from the GraphQL schema. As Michal already noticed in the linked Prisma issue, an update operation without any data is senseless. I will invest some time here on the weekend. |
After excecute npx prisma generate we have some Input Types that's are empty, so, when i tried to run the nest app i have the following Error:
that's my auto generated file:
The text was updated successfully, but these errors were encountered: