-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fixes issue #7549 #8497
fixes issue #7549 #8497
Conversation
🦋 Changeset detectedLatest commit: 858902a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@EandrewJones can you fix tests? |
I will take a look later today. All tests passed locally when I ran yarn
test, so I need to see which ones are failing.
…On Tue, Oct 18, 2022, 8:25 AM Saihajpreet Singh ***@***.***> wrote:
@EandrewJones <https://github.com/EandrewJones> can you fix tests?
—
Reply to this email directly, view it on GitHub
<#8497 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ2T6APKOPZVRSBKIWYVM23WD2JLVANCNFSM6AAAAAARHOGKGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@dotansimha I ran:
I believe this updated the types for the dev-test flow and should've fixed the issue. |
@EandrewJones, sadly it seems this change has broken all of my generated ContextOne example of a paginated query I am calling is export type EmployeesQueryVariables = Exact<{
paginationInput: WorkPaginationInput;
filterInput?: InputMaybe<WorkEmployeesFilterInput>;
sortInput: WorkEmployeeSortInput;
}>; I call it in the following way: const {
data,
fetchNextPage,
hasNextPage,
isFetching,
isFetchingNextPage,
isLoading,
isStale,
} = useInfiniteEmployeesQuery(
'paginationInput',
getClient(),
{
filterInput,
paginationInput: { first: PAGE_SIZE },
sortInput,
},
{
getNextPageParam,
onError: () => {
showToast('general', 'error');
},
}
); As you can see, IssueWhen the query is called for the first time, SolutionInstead of assuming that For example, in packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts: (metaData) => fetcher<${operationResultType}, ${operationVariablesTypes}>(client, ${documentVariableName}, {...variables, ...(metaData.pageParam ? { [pageParamKey]: metaData.pageParam } : {}}, headers)(), ConclusionOverall... I'm unsure about two things:
|
Thanks for your comment and I apologize for the breaking change. I will promptly add the ternary operator.
In my case, no. The page variable is indeed part of the variables and the page param was being updated but not correctly passed back into the variables because I couldn't define the key. I'm curious as to why the types generated for your infiniteQuery hooks correctly allowed for defining the pageParamKey but mine did not... AnswerIn fixing the PR, I've found the answer to my question. I am using a custom fetcher and the mapper (packages/plugins/typescript/react-query/src/fetcher-custom-mapper.ts) was missing the pageParamKey variable in the generated type. Whereas it wasn't missing in packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts. I didn't notice the inconsistency so erroneously assumed infinite queries were broken in the same way for all users and didn't consider the breaking change possibility. That would explain why more people weren't complaining about infinite queries not properly working. |
Description
In the typescript-react-query plugin, there are
useInfinite${operationName}Query
hooks. These require apageParamKey
to be specified in order for the hook to fetch the next page in paginated queries. Previously, this param was defined as a private param with a preceding '_' and was left unused in the call to the fetcher.I dropped the private underscore prefix
pageParamKey
and updated the fetcher call so that themetaData.pageParam
is passed to thepageParamKey
variable. This allows pagination function properly.Related dotansimha/graphql-code-generator-community#174
Type of change
Please delete options that are not relevant.
Screenshots/Sandbox (if appropriate/relevant):
N/A
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
packages/plugins/typescript/react-query/tests/react-query.spec.ts
) to match the new outputsCan be tested with:
Test Environment:
Checklist:
Further comments
N/A