dotansimha / dotansimha/graphql-code-generator-community
typescript-mongodb does not respect import-preset config
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
`@graphql-codegen/typescript-mongodb` does not respect presets such [near-operation-file-preset](https://www.graphql-code-generator.com/plugins/near-operation-file-preset) nor [import-types-preset](https://www.graphql-code-generator.com/plugins/import-types-preset).
for example typescript-resolvers will respect this setting and will change any `` to `Types.`:
```yml
# generate safe resolver types in the server
packages/server/src/graphql/generated/resolvers-types.ts:
documents: "packages/server/src/graphql/*.graphql"
preset: import-types
presetConfig:
typesPath: types.ts # Add Types. suffixes for each type
config:
typesSuffix: "QLType"
useIndexSignature: true
defaultMapper: Partial<{T}> # todo: remove this and add mappers from scheme DB
plugins:
- add:
content: "import * as Types from './types'" # import types from the generated types.ts
- typescript-resolvers
```
while these settings in typescript-mongodb just does not work:
```yml
# generate types for mongodb from graphql schema
packages/server/src/graphql/generated/mongodb.ts:
preset: import-types
presetConfig:
typesPath: types.ts # Add Types. suffixes for each type
plugins:
- add:
content: "import * as Types from './types'" # import types from the generated types.ts
- typescript-mongodb
config:
dbTypeSuffix: DBType
```
I've also looked at the the source files of both plugins, looks like `typescript-resolvers` will eventually will append prefix type `this.config.namspacedImportName` while the types generated by `typescript-mongodb` plugin does not respect any similar settings
allowing this option will allow us maintain more ordered and organized file structure for our type declaretions file and removing duplicated types.
by the way, thank you for this really awesome plugin!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.