Relates to #2137
This problem seems to be back in 1.8.1, or at least something related.
query {
user {
...UserFragment
}
}
Results in the Types import being added, even though it isn't used.
query {
user {
id
...UserFragment
}
}
Also adds the Types import, but uses it.
This is problematic when typescript is configured to error on unused imports.
Would love to see this solved, as we cannot use this preset with noUnusedLocals: true in tsconfig.json. Removing preResolveTypes: true also works.
Workaround I landed on (inspired by OP) is to duplicate a field from the fragment that uses Types (something optional, meaning Types.Maybe is used).
It's a bit tricky because it effects other use-cases. We are trying to find the actual specific use-cases that causes that.
@SimenB @mvestergaard can you please share a reproduction?
This was "fixed" for us by #4194 injecting usage of Types.Exact
This resurfaced for us, btw. We're back to adding dummy queries to work around it. I'll try to put together a reproduction
@SimenB sure, waiting for a reproduction. Thanks!
@dotansimha https://github.com/SimenB/codegen-extra-imports. Might be possible to reduce even more, but this is at least somewhat minimal
@dotansimha reopen this, or should I file a new issue?
@dotansimha reopen this, or should I file a new issue?
New issue :)