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

refactor: [M3-7440] - Upgrade to TanStack Query v4 #10236

Merged

Conversation

bnussman-akamai
Copy link
Member

@bnussman-akamai bnussman-akamai commented Feb 28, 2024

Description 📝

  • Updates us to React Query v4 (now called TanStack Query) 🎉
  • We are doing this so we can start using https://github.com/lukemorales/query-key-factory 🏭
    • We must upgrade first because query-key-factory isn't compatible with legacy React Query
  • The main changes are 🔧
    • Switching react-query to @tanstack/react-query
    • All queryKeys must be arrays (not string)
  • This PR does not attempt to make any clean up or improvement, it's goal is to just upgrade us without breaking anything.

Preview 📷

Note

No UI changes expected

How to test 🧪

  • Verify that all changes to queryKeys don't cause functionality regressions
  • Verify that all automated checks pass (especially e2es and unit tests)

As an Author I have considered 🤔

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@bnussman-akamai bnussman-akamai self-assigned this Feb 28, 2024
@bnussman-akamai bnussman-akamai marked this pull request as ready for review February 28, 2024 17:11
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner February 28, 2024 17:11
@bnussman-akamai bnussman-akamai requested review from mjac0bs and jaalah-akamai and removed request for a team February 28, 2024 17:12
@bnussman-akamai bnussman-akamai changed the title refactor: Upgrade to TanStack Query v4 refactor: [M3-7440] - Upgrade to TanStack Query v4 Feb 28, 2024
Copy link

github-actions bot commented Feb 28, 2024

Coverage Report:
Base Coverage: 81.34%
Current Coverage: 81.32%

Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this upgrade. It looks like there is now a TanStack Query v5 -- would it be worth upgrading to v5 now?

@@ -242,7 +242,7 @@ export const DatabaseSummaryConnectionDetails = (props: Props) => {
<Typography>
<span>password</span> = {password}
</Typography>
{credentialsLoading ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a related change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like if a query is mounted with enabled: false, isLoading is now true. Previously, it was false. We'll have to look out for any other places where this braking change causes issues.

See https://tanstack.com/query/v4/docs/framework/react/guides/migrating-to-react-query-4#disabled-queries

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh that's a curious implementation decision from the library.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are changes in this file related?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are an attempt to fix the existing flake caused by this test. I figured it wouldn't hurt.

@@ -90,13 +90,13 @@ const isValidRFC1918IPv4 = (address: string) => {
// 192.168.x.x (192.168/16 prefix)
return (
// check for valid 10.x IPs
// check for valid 192.x IPs
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm.. this might have been accidental

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the pre-commit hooks did this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the comment be moved back to the original location?

@hkhalil-akamai
Copy link
Contributor

hkhalil-akamai commented Feb 28, 2024

Thanks for tackling this upgrade. It looks like there is now a TanStack Query v5 -- would it be worth upgrading to v5 now?

Nvm, I just saw your comment on #10207. I'm good with moving to v4 first.

@bnussman-akamai
Copy link
Member Author

We won't do v5 just yet because it has even more breaking changes. I think the logical order for us will be

  1. Update to v4
  2. Implement a Query Key factory and clean up things (as we do this, we can prepare for the v5 breaking change https://tanstack.com/query/v5/docs/framework/react/guides/migrating-to-v5#supports-a-single-signature-one-object)
  3. Update to v5

Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for handling this upgrade! Did some local testing but overall am satisfied with E2E tests passing. The single failure looks unrelated.

@bnussman-akamai bnussman-akamai added Add'tl Approval Needed Waiting on another approval! React Query Relating to the transition to use React Query and removed Work in Progress labels Feb 28, 2024
Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Ran tests, reviewed changes and tested the application locally. All good from my vantage point ✅

Thanks for the update, excited to see our query key factory implemented as a follow up! 🎉

@bnussman-akamai bnussman-akamai removed the Add'tl Approval Needed Waiting on another approval! label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! React Query Relating to the transition to use React Query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants