offlineExchange import from @urql/exchange-graphcache not respecting `useTypeImports`
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<typeof offlineExchange>[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
graphqlversion:16.2@graphql-codegen/typescript-urql-graphcacheversion: 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
Created a PR that should fix this issue here too: https://github.com/dotansimha/graphql-code-generator-community/pull/1110