[React Query] addInfiniteQuery option imports QueryFunctionContext without usage
Hi there! I've been having lots of success with code generation using the React Query plugin.
Was adding the addInfiniteQuery option into my codegen.yml file, and noticed that it imports QueryFunctionContext from react-query unnecessarily according to my configuration. This sets off my ESLint rules, and I'm currently having to remove the import manually before committing any code.
The line in question is here: https://github.com/dotansimha/graphql-code-generator/blob/master/packages/plugins/typescript/react-query/src/visitor.ts
I've provided my codegen.yml below – perhaps it is an issue of my custom fetching function? Happy to push up a PR to resolve this.
overwrite: true
schema: "http://localhost:4000/v1/graph"
documents: "graphql/**/index.ts"
generates:
graphql/generated.ts:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-query"
config:
addInfiniteQuery: true
exposeFetcher: true
exposeMutationKeys: true
exposeQueryKeys: true
fetcher:
func: ../utils/gql-fetch#gqlFetch
fetchParams:
headers:
Content-Type: application/json
maybeValue: T
hooks:
afterOneFileWrite:
- prettier --write
We are also manually removing this unused import.
@jrwpatterson I believe it was added on the first commit that added the useInfiniteQuery hook (awesome job, this is working perfectly 👌, thank you) . Do you know how we can detect if this import is necessary, and only add it if it is?
https://github.com/dotansimha/graphql-code-generator/commit/f7a320a2d6378730e2b3b716c8b4184ac8c79640#diff-38f7b7f89098e5486e40c54e00569d09eb7b873bc8d4a7118aa39a1ce1c1be68R114
@evancloutier did you already submit a PR for this?
@evancloutier did you already submit a PR for this?
I haven't – I don't have the context on how or why the import is necessary.