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-8421] - Update Linode Types to use a Query Key Factory #10760

Conversation

bnussman-akamai
Copy link
Member

@bnussman-akamai bnussman-akamai commented Aug 7, 2024

Description 📝

  • Updates Linode Type Queries to use the Linodes Query Key Factory 🏭
  • Performs some small clean up 🧹

Preview 📷

Screenshot 2024-08-07 at 12 12 36 PM

How to test 🧪

  • Verify Linode types still load as expected throughout Cloud Manager 👁️
  • Verify automated testing passes ✅

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 added the React Query Relating to the transition to use React Query label Aug 7, 2024
@bnussman-akamai bnussman-akamai self-assigned this Aug 7, 2024
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner August 7, 2024 16:17
@bnussman-akamai bnussman-akamai requested review from mjac0bs and hkhalil-akamai and removed request for a team August 7, 2024 16:17
Comment on lines +31 to +37
initialData() {
const allTypesFromCache = queryClient.getQueryData<LinodeType[]>(
linodeQueries.types._ctx.all.queryKey
);

return allTypesFromCache?.find((t) => t.id === type);
},
Copy link
Member Author

Choose a reason for hiding this comment

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

This does the same thing getSingleType was doing. It checks the "all" query for the type as an optimization to save an extra fetch.

I'm using React Query's initialData option rather than the previous getSingleType approach because this allows us to keep the linodeQueries Query Key Factory "pure" (we can't use queryClient in the factory)

Copy link

github-actions bot commented Aug 7, 2024

Coverage Report:
Base Coverage: 82.42%
Current Coverage: 82.42%

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.

Great work! Verified types work across the app

Copy link
Contributor

@mjac0bs mjac0bs left a comment

Choose a reason for hiding this comment

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

Thanks! Can you add a Tech Story changeset?

✅ Not seeing any regressions in linode types throughout linodes and kube flows.
✅ Automated tests look good.

@mjac0bs mjac0bs added Approved Multiple approvals and ready to merge! Missing Changeset labels Aug 9, 2024
@bnussman-akamai bnussman-akamai merged commit d964675 into linode:develop Aug 12, 2024
19 checks passed
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