-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Hotfix for typescript react query infinite query breaking change #8567
Hotfix for typescript react query infinite query breaking change #8567
Conversation
🦋 Changeset detectedLatest commit: cc7f529 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your quick response and for opening a hotfix so quickly!
My apologies for breaking your code. There's nothing worse than updating a
package and everything stops working.
Best
Evan Jones
Website: www.ea-jones.com
…On Wed, Nov 2, 2022 at 6:16 PM Marc Müller ***@***.***> wrote:
***@***.**** approved this pull request.
Thank you so much for your quick response and for opening a hotfix so
quickly!
—
Reply to this email directly, view it on GitHub
<#8567 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ2T6AOJ4776QXFHTRPPLDLWGLR3TANCNFSM6AAAAAARVKNY4E>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
this is great work! lets get this merged :) |
Interesting, after updating I'm still getting tsc complaining about:
for infinite queries. any ideas? |
Hmm. I'll try to take a look at this tomorrow. Could you provide an example
of the query call you're making and the fetcher you're using?
Best
Evan Jones
Website: www.ea-jones.com
…On Fri, Nov 4, 2022 at 8:37 PM Wiley McKay Conte ***@***.***> wrote:
Interesting, after updating I'm still getting tsc complaining about:
Argument of type '{ [x: string]: any; }' is not assignable to parameter of type 'Exact<{ [key: string]: never; }>'.
'string' index signatures are incompatible.
Type 'any' is not assignable to type 'never'.
for infinite queries. any ideas?
—
Reply to this email directly, view it on GitHub
<#8567 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ2T6AKYCVEX3H4YMYCEZS3WGWT4BANCNFSM6AAAAAARVKNY4E>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hi @EandrewJones. Here is one example of this in a generated query: https://github.com/populist-vote/web/blob/w/upgrade-rq/generated.ts#L3676-L3679 Our codegen.yml: https://github.com/populist-vote/web/blob/w/upgrade-rq/codegen.yml And the associated .gql: https://github.com/populist-vote/web/blob/w/upgrade-rq/graphql/mutations/auth.graphql#L13-L33 Note, the offending generated hooks are for queries that we'll never need an infinite query for so perhaps there is a way to simply ignore these? I can get to get a minimal reproducible example if you need! Thanks for your attention on this |
Thanks for sharing.
Update: I probably won't be able to look deeply into this until Monday. Is
it breaking your type checks on commit/deploy?
Best
Evan Jones
Website: www.ea-jones.com
…On Sat, Nov 5, 2022 at 7:44 PM Wiley McKay Conte ***@***.***> wrote:
Hi @EandrewJones <https://github.com/EandrewJones>. Here is one example
of this in a generated query:
https://github.com/populist-vote/web/blob/w/upgrade-rq/generated.ts#L3676-L3679
Our codegen.yml:
https://github.com/populist-vote/web/blob/w/upgrade-rq/codegen.yml
And the associated .gql:
https://github.com/populist-vote/web/blob/w/upgrade-rq/graphql/mutations/auth.graphql#L13-L33
Note, the offending generated hooks are for queries that we'll never need
an infinite query for so perhaps there is a way to simply ignore these?
I can get to get a minimal reproducible example if you need! Thanks for
your attention on this
—
Reply to this email directly, view it on GitHub
<#8567 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ2T6AKPHD3FCLV5B7OY7HTWG3WO3ANCNFSM6AAAAAARVKNY4E>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
No worries, its breaking type checks on build but its not blocking or pressing at all. Thanks for investigating!
… On Nov 5, 2022, at 18:00, Evan Jones ***@***.***> wrote:
Thanks for sharing.
Update: I probably won't be able to look deeply into this until Monday. Is
it breaking your type checks on commit/deploy?
Best
Evan Jones
Website: www.ea-jones.com
On Sat, Nov 5, 2022 at 7:44 PM Wiley McKay Conte ***@***.***>
wrote:
> Hi @EandrewJones <https://github.com/EandrewJones>. Here is one example
> of this in a generated query:
> https://github.com/populist-vote/web/blob/w/upgrade-rq/generated.ts#L3676-L3679
>
> Our codegen.yml:
> https://github.com/populist-vote/web/blob/w/upgrade-rq/codegen.yml
>
> And the associated .gql:
> https://github.com/populist-vote/web/blob/w/upgrade-rq/graphql/mutations/auth.graphql#L13-L33
>
> Note, the offending generated hooks are for queries that we'll never need
> an infinite query for so perhaps there is a way to simply ignore these?
>
> I can get to get a minimal reproducible example if you need! Thanks for
> your attention on this
>
> —
> Reply to this email directly, view it on GitHub
> <#8567 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AJ2T6AKPHD3FCLV5B7OY7HTWG3WO3ANCNFSM6AAAAAARVKNY4E>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub <#8567 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AHLDEUPZDZF2L74G5YCPQOTWG3YIRANCNFSM6AAAAAARVKNY4E>.
You are receiving this because you commented.
|
Are the type warnings appearing in https://github.com/populist-vote/web/blob/w/upgrade-rq/generated.ts itself or in front-end front-end query calls itself? I'm a bit confused on where you're seeing the issue since you said the offending hooks are for queries that you'll never need an infinite query for, which suggests to me that the warnings must be in the generated.ts file itself. Is the entire query underlined by your linter or just a specific part? I'm trying to replicate this but I can't. |
I'm not consuming any of the offending generated hooks. The warnings are indeed in the generated file:
However, I am noticing that one of the infinite query hooks that I am consuming is now failing at runtime when making a call for the next page.
The hooks usage looks like this:
In debugging, i've logged out Let me know if you need any other information, thank you |
Type MismatchThe issue with the type checking is that CurrentUserQuery doesn't accept any variables. So there's a type mismatch between the type definition for and the unpacking that's happening during pagination: {
...variables,
...(metaData.pageParam ? { [pageParamKey]: metaData.pageParam } : {}),
} What confuses me here is how you're storing currentUser (client-side state) in a database and looking it up without passing any variables such as a userId to the query?? For example, I see similar logic in DeleteAccount: https://github.com/populist-vote/web/blob/37fb984b378497cfc7de572301287bd92ec98df4/generated.ts#L1947 How does the back end know which account to delete if you're not passing a key of some sort? I'm definitely missing something important here. Fix for the broken calls
Well this one is more apparent: your getNextPageParam: (lastPage) => {
if (!lastPage.politicians.pageInfo.hasNextPage) return ''; // Might need to change this to undefined or change the logic so this callback isn't even triggered unless hasNextPage is true
return lastPage.politicians.pageInfo.endCursor;
}, The way the code was changed, the infiniteQuery no longer unpacks the pageParam object Originally, I thought this was the issue, but now I believe all I needed to fix was the missing pageParamKey argument in the custom-fetcher generation files... |
Also experiencing this issue. Is there already an issue to track it? Not sure if it's dotansimha/graphql-code-generator-community#227 |
@blaenk Yes this is tracking the issue. This is on my radar and I'll try to figure out the appropriate solution in a new PR soon. |
Thanks for the info on the infiniteQuery hook, I will give that a shot later today. Per my getCurrentUser and deleteAccount queries, they do not require any variables to be be passed because they rely on an http only cookie that is passed with the request which provides the server with all the context it needs to get/delete the user record |
@wileymc Cookie-based -- got it. Makes sense. |
Also having this error for queries without any variables |
I spent some time looking into this. A conditional check against queryVariables that are of type I think a reversion to the original variable unpacking implementation is the only choice since I don't believe that was the original source of my issue and it also worked fine with your code. Original unpacking implementation: {...variables, ...(metaData.pageParam ?? {})} @wileymc This would mean that the fix for broken calls I gave you above would no longer work, but your prior implementation would. If this sounds good by you, I'll go ahead and implement. |
Curious what that 'prior implementation' is? I'm interested as someone who didn't make any changes to my graphql-codegen config but can't currently generate code due to this issue. Do you mean that it will now work again without any changes, or is some change necessary and if so what is it? I personally don't mind if any changes are necessary, I'm just curious what it would entail. Thank you so much for looking into this and working on it @EandrewJones! |
Thanks for taking a look! I decided to set Because I don't have many queries that I need the infinite hook for, this is great for now and I don't have a preference for which implementation you go with. |
@blaenk Sorry for the vague language. By "prior implementation", I was referring to the getNextPageParam in @wileymc's code which broke when I made the original change. If you haven't made any changes to your code to try to address the change introduced in this PR, then reverting should return your existing code to working state. The original way nextPageParam variables were unpacked and passed back into the query was: {...variables, ...(metaData.pageParam ?? {})} I thought this was a partial source of the issue I encountered because the pageParamKey wasn't being passed in during unpacking (unless you explicitly returned an object from the getNextPageParam function with the pageParamKey e.g. |
If by this you mean reverting the package version, yeah I pinned it to the previously working version, I didn't mean to convey I'm currently in a broken state, I only meant that it's broken with the current version 👍🏼 So if I understand you correctly, having not made any changes other than pinning to the previously working version, once the fix is out, the intention is that it'll work by simply upgrading to it. Thanks again for your work on this! |
@blaenk That is the intention. Will update this thread when the PR is in. Might be a few days because of holidays. |
any update on this? |
@hwennnn I've basically been stuck waiting on a reveiwer/admin to merge the dang PR. The changes have been sitting and waiting. I pinged the reviewer on the PR to see if we can get this in. |
Looks like that other PR you mentioned is now merged. Nice work! |
Yes, thanks for all the nudges -- this slipped off my radar as it did the
reviewer's. The codebase should now be almost completely reverted.
Best
Evan Jones
Website: www.ea-jones.com
…On Tue, Jan 17, 2023 at 12:39 AM Jorge Israel Peña ***@***.***> wrote:
Looks like that other PR you mentioned is now merged. Nice work!
—
Reply to this email directly, view it on GitHub
<#8567 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ2T6AP7MYQ6EKEWGTQRGU3WSYWAZANCNFSM6AAAAAARVKNY4E>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
It does appear to work for me, thanks again for your contribution on this! |
Thanks for the confirmation.
Best
Evan Jones
Website: www.ea-jones.com
…On Tue, Jan 17, 2023 at 1:50 PM Jorge Israel Peña ***@***.***> wrote:
It does appear to work for me, thanks again for your contribution on this!
—
Reply to this email directly, view it on GitHub
<#8567 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ2T6AKT74D7IK2D63W4QP3WS3SX5ANCNFSM6AAAAAARVKNY4E>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Description
As per @marcmll's comment #8497 (comment), the change introduced in PR #8497 breaks infinite query calls for some users if
pageParam
is undefined which happen on the first call.Related #8566
The code now safeguards against this via a ternary operator that check whether pageParam is defined and only overwrites variable value when it's defined.
Type of change
Please delete options that are not relevant.
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
Test Environment:
Checklist: