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

fix useBackgroundQuery: dispose ref after unmount and not used #11696

Merged

Conversation

PiR1
Copy link
Contributor

@PiR1 PiR1 commented Mar 18, 2024

Fixes: #11649, based on tests created in this pull request: #11651

@PiR1 PiR1 requested a review from a team as a code owner March 18, 2024 18:43
Copy link

netlify bot commented Mar 18, 2024

👷 Deploy request for apollo-client-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 1083346

Copy link

changeset-bot bot commented Mar 18, 2024

🦋 Changeset detected

Latest commit: 1083346

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

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

@jerelmiller jerelmiller self-assigned this Mar 18, 2024
Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @PiR1 👋

Thanks so much for the contribution! This definitely seems in line with some ideas I had on fixing this, so this change makes sense.

I spotted a couple things that may or may not be problematic. Would you mind taking a look at those comments? Thanks again!

src/react/internal/cache/QueryReference.ts Outdated Show resolved Hide resolved
src/react/internal/cache/QueryReference.ts Outdated Show resolved Hide resolved
src/react/internal/cache/QueryReference.ts Outdated Show resolved Hide resolved
@PiR1 PiR1 requested a review from jerelmiller March 20, 2024 18:19
Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is starting to look really great! I had a few more suggestions on naming and the API itself, but generally I'm pretty happy with this direction. This should be my last round of changes barring any other edge cases I can think of.

src/react/internal/cache/QueryReference.ts Outdated Show resolved Hide resolved
src/react/internal/cache/QueryReference.ts Outdated Show resolved Hide resolved
.changeset/fast-roses-kick.md Outdated Show resolved Hide resolved
src/react/internal/cache/QueryReference.ts Outdated Show resolved Hide resolved
@jerelmiller
Copy link
Member

Don't worry about the size and API extractor jobs failing. I'll make sure those get updated before this is merged 🙂

@PiR1 PiR1 requested a review from jerelmiller March 21, 2024 22:31
Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🔥 💯 This looks great! Thanks so much for diving into the the depths of QueryReference to fix this! This is a really great optimization.

@jerelmiller
Copy link
Member

@PiR1 if you wouldn't mind making sure the formatting job passes, I'll get the size/api extractor updated to pass. I'll get this merged in as soon as these are all green.

@PiR1
Copy link
Contributor Author

PiR1 commented Mar 21, 2024

@jerelmiller Thank you very much for all the feedback and explanations!
It was very interesting, thank you for your time.

@jerelmiller
Copy link
Member

Absolutely! I hope to see more contributions from you in the future! (if you're interested of course 🙂 )

@jerelmiller jerelmiller merged commit 466ef82 into apollographql:main Mar 21, 2024
29 checks passed
This was referenced Mar 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Background query still active after component unmounted
2 participants