Open arcanis opened 4 years ago
The actual issue here is the fact that we are applying the flattenGeneratedTypes
on the level of the plugin, after the preset has been executed and all operations has been splitted to separate output files.
That means, that we get a file for the fragment, and a file for the operation, but the operation needs to flatten the selection set and remove the fragment completely. Some kind of a race condition.
To get this solved, we need to apply the optimizeDocuments
method on the level of the loaders in graphql-tools
, and allow to pass the flag there - this way it will allow us to optimize operations before codegen preset gets it.
@ardatan fyi :)
We are also running into this (https://github.com/dotansimha/graphql-code-generator/issues/6199).
The bug
label was removed a few days ago. Is there a solution for how this can be fixed through config or why is this not considered a bug?
I'm continuing to run into errors due to this issue and I'd love to see a fix for it 🙂
I'm in the process of incrementally migrating from Apollo code-generated typedefs to graphql-code-generator typedefs and this is the last issue that prevents full interoperability between the two.
To get this solved, we need to apply the optimizeDocuments method on the level of the loaders in graphql-tools, and allow to pass the flag there - this way it will allow us to optimize operations before codegen preset gets it.
I tried digging into the graphql-tools code to accomplish this, but I couldn't get it to work. It was a while ago and I was just hacking around in the built lib within my node_modules
so I don't remember exactly what I tried 😅 I remember getting some errors about unknown or unrecognized fragments, I think 🤔
@dotansimha, @ardatan, are there any additional details or files you could point me to where the change should be made? I'd be happy to give it another try in a more rigorous way.
Thanks 🙏🏻
Up, have the same issue
Yes, this is not solved yet
Still having this issue.
Bump
Describe the bug Using the
flattenGeneratedTypes
option (required to workaround https://github.com/dotansimha/graphql-code-generator/issues/4212) causes GraphQL to fail to locate fragments when usingnear-operation-file-preset
and the fragments are located in other files (regardless whether the queries are written in.graphql
or.ts
files w/ imports).Similar to https://github.com/dotansimha/graphql-code-generator/issues/528
To Reproduce https://codesandbox.io/s/empty-fast-xl915?file=/codegen.yml
Expected behavior Should compile fine with or without
flattenGeneratedTypes
.Environment: n/a