graphql-code-generator-community
graphql-code-generator-community copied to clipboard
[typescript react-query] unused `pageParamKey` when calling `useInfiniteQuery`.
Describe the bug
Unused pageParamKey in file https://github.com/dotansimha/graphql-code-generator/blob/master/packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts
I think this:
return `export const useInfinite${operationName} = <
TData = ${operationResultType},
TError = ${this.visitor.config.errorType}
>(
pageParamKey: keyof ${operationVariablesTypes},
client: GraphQLClient,
${variables},
${options},
headers?: RequestInit['headers']
) =>
${hookConfig.infiniteQuery.hook}<${operationResultType}, TError, TData>(
${generateInfiniteQueryKey(node, hasRequiredVariables)},
(metaData) => fetcher<${operationResultType}, ${operationVariablesTypes}>(client, ${documentVariableName}, {...variables, ...(metaData.pageParam ?? {})}, headers)(),
options
);`;
should be change to:
return `export const useInfinite${operationName} = <
TData = ${operationResultType},
TError = ${this.visitor.config.errorType}
>(
pageParamKey: keyof ${operationVariablesTypes},
client: GraphQLClient,
${variables},
${options},
headers?: RequestInit['headers']
) =>
${hookConfig.infiniteQuery.hook}<${operationResultType}, TError, TData>(
${generateInfiniteQueryKey(node, hasRequiredVariables)},
(metaData) => fetcher<${operationResultType}, ${operationVariablesTypes}>(client, ${documentVariableName}, {...variables, [pageParamKey]: metaData.pageParam }, headers)(),
options
);`;
Any intention to fix this or should I create a PR?
The infinite query does not work correctly if it isn't passing the page param to the correct variable. Plus, even if you write a temporary solution, the generator overwrites the fix anytime you update your api and need to regenerate the hooks.
@EandrewJones go for it! Would love to review and land it in :)
Great -- will look to push something in the coming week or two.
Best
Evan Jones Website: www.ea-jones.com
On Sun, Oct 16, 2022 at 10:52 AM Saihajpreet Singh @.***> wrote:
@EandrewJones https://github.com/EandrewJones go for it! Would love to review and land it in :)
— Reply to this email directly, view it on GitHub https://github.com/dotansimha/graphql-code-generator-community/issues/174, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ2T6AKUYIEJSUNZNUCLH63WDQJCNANCNFSM5OR5NJPA . You are receiving this because you were mentioned.Message ID: @.***>
@saihaj Will you please assign me the issue?
Did this change get lost? I'm on 4.1.0 and this still happens
yah same - wondering what this is?
Yes same here, I have now this unused param
also having this issue, seems something was reverted
Same here
also same 😢
Seems like the fix was reverted here (https://github.com/dotansimha/graphql-code-generator-community/pull/25) due to another bug
still same ...
@happyso you are facing issue in @graphql-codegen/[email protected]?