Describe the bug
My team is currently generating hooks with no components nor HOCs when no mutations or subscriptions are implemented. We have found an issue where import * as ReactApollo from 'react-apollo' is generated in the file but is not being used, therefore gets flagged by Typescript noUnusedLocals
To Reproduce
Steps to reproduce the behavior:
codegen.yml config file:documents: src/apollo/**/!(schema).graphql
overwrite: true
generates:
src/apollo/index.tsx:
schema: src/apollo/**/schema.graphql
plugins:
- add: /* THIS IS A GENERATED FILE - DO NOT MODIFY */
- add: /* eslint-disable */
- typescript
- typescript-operations
- typescript-react-apollo
config:
gqlImport: graphql-tag.macro
withComponent: false
withHooks: true
withHOC: false
Expected behavior
Unused imports should not be generated.
Environment:
@graphql-codegen/...: 1.1.3Hi @bpallares ! Thank you for reporting this.
It seems like you are getting this error because of TypeScript configuration, and it seems like it's not possible to ignore specific files (https://github.com/Microsoft/TypeScript/issues/12913).
@ardatan can you please take a look and see why those imports are being generated?
@bpallares Could you confirm if it works correctly with the following canary version?
@graphql-codegen/typescript-react-apollo => 1.1.4-alpha-de90829b.24+de90829b
@ardatan It works correctly with the canary version provided!
Fixed in 1.2.0.