dotansimha / dotansimha/graphql-code-generator-community

Preset import-types not importing typescript-operations in all my files

Open
#103 6 comments 5 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

**Describe the bug**
I have a monorepo with a root codegen.yml including this:
```yml
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...)


goodfile
badfile

**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 !

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.