dotansimha / dotansimha/graphql-code-generator-community
offlineExchange import from @urql/exchange-graphcache not respecting `useTypeImports`
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Which packages are impacted by your issue?
@graphql-codegen/typescript-urql-graphcache
### Describe the bug
The code generator adds an import for `offlineExchange` from '@urql/exchange-graphcache', but it is not using the `config.useTypeImports` config to determine if the import should by type import.
`offlineExchange` is only used in the following generated code (which only requires types):
```
export type GraphCacheConfig = Parameters[0] & {
updates?: GraphCacheUpdaters,
keys?: GraphCacheKeysConfig,
optimistic?: GraphCacheOptimisticUpdaters,
resolvers?: GraphCacheResolvers,
};
```
Using the library with `importsNotUsedAsValues` set to `error` will throw an error with the imported code.
### Your Example Website or App
https://stackblitz.com/edit/github-pg6z88?file=package.json
### Steps to Reproduce the Bug or Issue
Open stackblitz, and run `npm run check`
### Expected behavior
tsc command succeeds, instead it throws an error.
### Screenshots or Videos
_No response_
### Platform
- OS: macOS
- NodeJS: 18.18
- `graphql` version:16.2
- `@graphql-codegen/typescript-urql-graphcache` version: 3.0.0
### Codegen Config File
```
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'schema.graphql',
documents: 'document.graphql',
generates: {
'types.ts': {
config: {
useTypeImports: true,
},
plugins: [
'typescript',
'typescript-operations',
'typescript-urql-graphcache',
],
},
},
};
```
export default config;
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.