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-7437] - Prepare Profile Queries for React Query v5 #9991

Conversation

bnussman-akamai
Copy link
Member

Description 📝

Changes of plans: No feature branch for the React Query update project. We will do all of the required changes first (merging to develop) then bump the React Query version last. This will eliminate the need for a feature branch.

Changes 🔄

  • This PR updates our profile related queries to
    • Use a Query Key Factory 🏭 to help with type safety and organization 🗂️
      • Also enforces query keys are Array (required for React Query v4)
    • Use a single object when defining the react query hook 1️⃣ (required for React Query v5)

How to test 🧪

Important

These code changes should result in no changes to the functionality/behavior of Cloud Manager. It is simply a migration to newer patterns.

Verification steps

  • Check out this PR
  • Test general functionality of Profile related features
    • Verify you profile loads
    • Verify grants load for restricted users
    • Verify your SSH keys load
    • Verify your App tokens load
    • Verify your PATs load

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 Work in Progress React Query Relating to the transition to use React Query labels Dec 12, 2023
@bnussman-akamai bnussman-akamai self-assigned this Dec 12, 2023
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner December 12, 2023 20:23
@bnussman-akamai bnussman-akamai requested review from dwiley-akamai and tyler-akamai and removed request for a team December 12, 2023 20:23
Copy link

github-actions bot commented Dec 12, 2023

Coverage Report:
Base Coverage: 77.5%
Current Coverage: 77.52%

Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

Profile loads ✅
Grants load for restricted users ✅
SSH keys load ✅
App tokens load ✅
PATs load ✅

@@ -1609,6 +1609,11 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@bnussman/query-key@0.0.7":
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we create this as a package under the Linode/Akamai org?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's the plan! 📦 I will go over this package in the next cafe and we can proceed based on how the cafe discussion goes.

packages/manager/src/queries/profile.ts Show resolved Hide resolved
@tyler-akamai
Copy link
Contributor

tyler-akamai commented Dec 13, 2023

Verified:

  • Profile loads
  • Grants load for restricted users
  • SSH keys load
  • App tokens load
  • PATs load

queryFn: () => getPersonalAccessTokens(params, filter),
queryKey: [params, filter],
}),
profile: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might cause conflicts with my current changes since getProfile now takes an optional header argument.

I think a simple fix would be:
queryFn: getProfile, --> queryFn: () => getProfile(),

But I can even add this in my PR if this is merged before that

@tyler-akamai
Copy link
Contributor

LGTM 🚀

Its def cleaner and more consistent, great job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React Query Relating to the transition to use React Query Ready for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants