Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript react-query] unused pageParamKey when calling useInfiniteQuery. #174

Open
ndthinh8796 opened this issue Feb 16, 2022 · 13 comments
Assignees

Comments

@ndthinh8796
Copy link

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
    );`;
@EandrewJones
Copy link
Contributor

EandrewJones commented Oct 14, 2022

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.

@saihaj
Copy link
Collaborator

saihaj commented Oct 16, 2022

@EandrewJones go for it! Would love to review and land it in :)

@EandrewJones
Copy link
Contributor

EandrewJones commented Oct 16, 2022 via email

@EandrewJones
Copy link
Contributor

@saihaj Will you please assign me the issue?

EandrewJones referenced this issue in EandrewJones/graphql-code-generator Oct 17, 2022
@saihaj saihaj assigned saihaj and EandrewJones and unassigned saihaj Oct 17, 2022
EandrewJones referenced this issue in EandrewJones/graphql-code-generator Oct 18, 2022
charlypoly referenced this issue in dotansimha/graphql-code-generator Oct 20, 2022
Co-authored-by: Charly POLY <1252066+charlypoly@users.noreply.github.com>
saihaj referenced this issue in dotansimha/graphql-code-generator Nov 4, 2022
* fixes issue #7549

* update dev-test types #7549

* Create sweet-nails-tie.md

* fix breaking change in #8566; optionally pass metaData.pageParam to pageParamKey only when it is defined

Co-authored-by: Charly POLY <1252066+charlypoly@users.noreply.github.com>
@dotansimha dotansimha transferred this issue from dotansimha/graphql-code-generator Feb 5, 2023
@StampixSMO
Copy link

Did this change get lost? I'm on 4.1.0 and this still happens

@tonypee
Copy link

tonypee commented Feb 14, 2023

yah same - wondering what this is?

@pigeonvictor
Copy link

Yes same here, I have now this unused param

@giubatt
Copy link
Contributor

giubatt commented Apr 7, 2023

also having this issue, seems something was reverted

@sumicet
Copy link

sumicet commented Apr 20, 2023

Same here

@gabrielavoll
Copy link

also same 😢

@saalihou
Copy link

Seems like the fix was reverted here (#25) due to another bug

@happyso
Copy link

happyso commented Nov 23, 2023

still same ...

@saihaj
Copy link
Collaborator

saihaj commented Nov 23, 2023

@happyso you are facing issue in @graphql-codegen/typescript-react-query@5.0.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests