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
Fix issue where selection set flattening uses the wrong parent type #6874
Fix issue where selection set flattening uses the wrong parent type #6874
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/theguild/graphql-code-generator/2ETS7kSXQwHG1kwQht6mb9eZ58ZH |
Hey @mvestergaard, thank you for debugging this and finding a fix that works for your code-base! Did you manage to track down which operation caused this issue? If we have the schema and operation combination it shouldn't be impossible to solve this 🤔 I wanna merge this, but we really need a test for it! |
I get that, and unfortunately no. With this fix, I managed to at least get the types for our code base built. However the types that were built were full of errors, so there are other things blocking us from upgrading as well. We use some kinda niche features like near-operations-file, and a custom wrapper for the apollo tooling, which seems to be things that break every other release of this project 😢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mvestergaard The screenshots you shared give some hint on which field/types caused these issues. I suggest you single out the operation that causes this, based on those screenshot hints.
Unfortunately, I cannot merge this pull request without a test case that shows how these changes actually solve an issue and prevent a future regression.
I hope you can understand that.
Of course... I can look at it again and try to find the root cause when time permits. I'll change this to a draft in the meantime. |
1a4493a
to
ff30197
Compare
9ea19ea
to
7673256
Compare
#8664 Adds this fix, along with a test, closing this one. |
Description
So let me just start out by saying that I've tried pretty much everything to replicate this problem in a small example. I even took our huge GQL schema into a sandbox and tried writing various queries to replicate the problem, without luck.
The gist of this is basically that after upgrading to the newer versions of the generator, we get this error:
After a ton of debugging, I arrived at this suggested solution. Here are some screenshots to try and explain what is going wrong:
At this point where flattenSelectionSet is called, the block scoped
parentSchemaType
isClientPerson
, but the class scoped_parentSchemaType
isGetClientResult
GetClientResult
is a union type consisting of eitherClientPerson
orClientCompany
or one of a few error types.The problem with this is that it ends up with a flattened list of fields, that contain fields specific to
ClientCompany
, which it then tries to apply toClientPerson
.Pretty sure this is the same issue reported in #5061
I've also found that setting
preResolveTypes
tofalse
, and/orinlineFragmentTypes
tocombine
will prevent the issue as well. I think that basically reverts to older behavior, but I assume you changed the defaults for a reason.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
It has been tested on our very large schema and code base. As mentioned, I have not found a way to create a small replication of the issue. I have therefore not been able to write a test for it either.