T
TanStack14mo ago
constant-blue

Blog post reviews requested

I made a blog post about using Angular query in route guards. @arnoud or anyone who is willing, can you take a look and make sure it is factually correct?
6 Replies
rising-crimson
rising-crimson14mo ago
Hi, yeah I can do that
constant-blue
constant-blueOP14mo ago
DEV Community
Angular Query in route guards
Short version Use queryClient.fetchQuery(...), which returns the data as a...
rising-crimson
rising-crimson14mo ago
Coincidently at my current project we just made a route guard using Query ourselves
constant-blue
constant-blueOP14mo ago
Nice! It may be a good idea to add an example in the documentation.
rising-crimson
rising-crimson14mo ago
I will take a more in depth look later, but we choose to use ensureQueryData Yes, if you'd want to do that would be great Hi, reviewed it. Good article! I do not have much feedback, maybe a tiny one: change staleTime in the first code snippet to 30_000 and mention in a comment that it should be greater than 0. I’ve seen people confused when they copy / paste a code snippet and it doesn’t work right away. I like how you mention that injectQuery works great for components and not for route guards. This is indeed how it should be used. Also cool to see the pattern of returning queryOptions from a service in your article.
constant-blue
constant-blueOP14mo ago
Thanks for the review! That is updated now. And thank you for your encouraging words.

Did you find this page helpful?