Preset import-types not importing typescript-operations in all my files
Describe the bug I have a monorepo with a root codegen.yml including this:
generates:
packages/api/src/types/common.ts:
plugins:
- 'typescript'
- 'typescript-operations'
packages/api/src/types/models.ts:
preset: import-types
presetConfig:
typesPath: './common'
plugins:
- 'typescript-react-apollo'
- 'fragment-matcher'
packages/api/src/types/auth-models.ts:
preset: import-types
presetConfig:
typesPath: './common'
plugins:
- 'typescript-graphql-request'
- 'fragment-matcher'
In packages/api/src/types/models.ts, the operation's types are well imported from './common' (Types.InterfaceX) But in packages/api/src/types/auth-models.ts, the operation's types are not prefixed by 'Types.' so it doesn't find them... Why is there a difference between those 2 files please ? (If I only put the typescript's pluggin in the common file and let the typescript-operations in the specifics files, the types are well imported from common in both files...)
To Reproduce Steps to reproduce the behavior:
Generate types with 'typescript' and 'typescript-operations' pluggins in one file. Generate types with 'typescript-graphql-request' pluggin using "preset: import-types" and "presetConfig: typesPath: './path/to/common/file'"
Expected behavior To have my 'typescript-operations' types imported from my common file in both specific files ('Types.CommonType' instead of 'CommonType').
Environment:
- OS: macOS 11.0.1
- NodeJS: 14.15.1
- "@graphql-codegen/fragment-matcher": "2.0.1", "@graphql-codegen/import-types-preset": "1.18.1", "@graphql-codegen/introspection": "1.18.1", "@graphql-codegen/typescript": "1.19.0", "@graphql-codegen/typescript-graphql-files-modules": "1.18.1", "@graphql-codegen/typescript-graphql-request": "2.0.3", "@graphql-codegen/typescript-operations": "1.17.12", "@graphql-codegen/typescript-react-apollo": "2.2.1":
Additional information I also tried to add config 'importOperationTypesFrom' for @graphql-codegen/typescript-graphql-request but that didn't generate anything different...
Thank you very much !
I felt onto the same problem and looked up importOperationTypesFrom in the codebase. It seems typescript-graphql-request did not even use it. But I see usage in vue-apollo, react-apollo, react-query
@lanwin is right. Not all plugins support all flags and all combinations with presets. We are trying to track those and fix, so we might found another one :) I guess in this case, it's an issue only with typescript-graphql-request plugin, right?
I guess in this case, it's an issue only with typescript-graphql-request plugin, right?
I dont use Preset but I would bet its the same issue. So 👍
Any updates on this?
Still needing this behavior!!!! Any updates?
Need this too, please give us an update.