dotansimha / dotansimha/graphql-code-generator-community

typescript-react-apollo: Invalid TypeScript output when both withHOC and useTypeImports are true

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

Description

**Describe the bug**

When using `typescript-react-apollo` plugin, and enabling both `withHOC` and `useTypeImports` output is not a valid TypeScript file:
```ts
import * as ApolloReactHoc from '@apollo/client/react/hoc';
import type * as ApolloReactHoc from '@apollo/client/react/hoc';
```

**To Reproduce**
Steps to reproduce the behavior:
1. Open live-demo
2. Choose the `Operations types` template
3. Change the config to one below

1. My GraphQL schema:

```graphql
# Default from demo
```

2. My GraphQL operations:

```graphql
# Default from demo
```

3. My `codegen.yml` config file:

```yml
generates:
types-and-hooks.tsx:
config:
withHOC: true
useTypeImports: true
plugins:
- typescript
- typescript-react-apollo
```

**Expected behavior**

Only this line should be in the output:
```ts
import * as ApolloReactHoc from '@apollo/client/react/hoc';
```

**Actual behavoir**
Both lines are in the output:
```ts
import * as ApolloReactHoc from '@apollo/client/react/hoc';
import type * as ApolloReactHoc from '@apollo/client/react/hoc';
```
**Environment:**
Using the live-demo reproduces it

- OS:
- `@graphql-codegen/...`:
- NodeJS:

**Additional context**

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.