-
Notifications
You must be signed in to change notification settings - Fork 361
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
refactor: [M3-8421] - Update Linode Types to use a Query Key Factory #10760
Conversation
initialData() { | ||
const allTypesFromCache = queryClient.getQueryData<LinodeType[]>( | ||
linodeQueries.types._ctx.all.queryKey | ||
); | ||
|
||
return allTypesFromCache?.find((t) => t.id === type); | ||
}, |
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.
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)
Coverage Report: ✅ |
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.
Great work! Verified types work across the app
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.
Thanks! Can you add a Tech Story changeset?
✅ Not seeing any regressions in linode types throughout linodes and kube flows.
✅ Automated tests look good.
Description 📝
Preview 📷
How to test 🧪
As an Author I have considered 🤔