dotansimha / dotansimha/graphql-code-generator
support for importing mapper as default more than once
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Describe the bug**
I am using `typescript-resolvers` with configured `mappers` to integrate my ORM entities with my API. My entities are exported from their individual files as default.
My goal now is to begin a data type migration by adding the same entity to my API in two places. However, when I try to import the single entity with two identifiers, the generated import code only imports the first identifier.
This appears to be a limitation in `BaseResolversVisitor#buildMapperImport` where it assumes that a default import will only have one identifier.
https://github.com/dotansimha/graphql-code-generator/blob/563c9dc9007d36b026f84258443c4df31603558f/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts#L732
**To Reproduce**
CodeSandbox failed to load with a `502 Bad Gateway`. I hope my description and code link should be enough to confirm the issue.
1. My GraphQL schema:
```graphql
type Query {
model: MyModel
newModel: MyNewModel
}
```
2. My GraphQL operations:
n/a
3. My `codegen.yml` config file:
```yml
generates:
src/schema.ts:
plugins:
- typescript
- typescript
config:
mappers:
MyModel: ./MyModel#default
MyNewModel: ./MyModel#default
```
**Expected behavior**
```typescript
import MyModel from `./MyModel`;
import MyNewModel from `./MyModel`;
```
**Environment:**
- OS: Linux
- `@graphql-codegen/...`: 1.17.7
- NodeJS: 14.x
**Additional context**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.