Earlier quoted context omitted.
which is likely much better than making the wrong assumption because you know what "cache" means. Check the docs, cacheTime is very likely not doing what you expected. A typical expectation would be that "cacheTime" controls how long react query uses the cached value before it tries to fetch that data again from the server. That part is actually controlled by "staleTime".
It's a fair point that I agree with. I meant more in terms of, why not just name it `garbageCollectTime`.
TanStack Query(a.k.a. React Query) v5 announced
51–60 of 64 posts
Re: TanStack Query(a.k.a. React Query) v5 announced
#52It’s worth noting you can autogenerate TanStack Query clients in a typesafe way using graphql-codegen, really saves a lot of time!
Re: TanStack Query(a.k.a. React Query) v5 announced
#53Our team is currently debating whether we should adopt react-query or stick with plain old hand-written code around `fetch`. The team used Apollo in another project, so we are quite familiar with a "heavy handed wrapper" around backend requests. But I'm not sure the added complexity of react-query is "worth it". Anyone have experiences to share, either using react-query, a different library or particularly painful me…
In my opinion react query doesn't really add complexity if you just use to "await" your fetches. It even comes with the nice added functionality to refetch everything when refocusing the browser. And some automatic error handling. Once you need query invalidation it gets really useful. But it also depends how you use fetch right now. If you do it on per-route basis, than react query might not bring a lot of benefits.
Re: TanStack Query(a.k.a. React Query) v5 announced
#54Our team is currently debating whether we should adopt react-query or stick with plain old hand-written code around `fetch`. The team used Apollo in another project, so we are quite familiar with a "heavy handed wrapper" around backend requests. But I'm not sure the added complexity of react-query is "worth it". Anyone have experiences to share, either using react-query, a different library or particularly painful me…
I would suggest taking a look at SWR [0]. I think it strikes a very nice balance between using fetch and something more heavy-handed like React Query. [0] https://swr.vercel.app/
[0] https://the-guild.dev/openapi/fets/client/quick-start [1] https://openapi-ts.pages.dev/openapi-fetch/
Re: TanStack Query(a.k.a. React Query) v5 announced
#55Our team is currently debating whether we should adopt react-query or stick with plain old hand-written code around `fetch`. The team used Apollo in another project, so we are quite familiar with a "heavy handed wrapper" around backend requests. But I'm not sure the added complexity of react-query is "worth it". Anyone have experiences to share, either using react-query, a different library or particularly painful me…
I spent a couple of years on a project that used React Query with Axios. The massive advantage over plain fetch was the middleware API. If you want to do things like injecting an auth header or clientside token refresh it's really useful. That was more Axios than React Query though.
The only option I saw was to wrap `useQuery` so that you can do custom shenanigans like hooking up the abort signal to the fetch requests.
Re: TanStack Query(a.k.a. React Query) v5 announced
#56Our team is currently debating whether we should adopt react-query or stick with plain old hand-written code around `fetch`. The team used Apollo in another project, so we are quite familiar with a "heavy handed wrapper" around backend requests. But I'm not sure the added complexity of react-query is "worth it". Anyone have experiences to share, either using react-query, a different library or particularly painful me…
Best thing you could do, spend some time learning how it works properly (query keys, invalidations... ) and how you'd set up things like pagination. If at any point anyone goes like "oh it doesn't seem to support this, we'll have to write some wrappers/custom stuff", take a step back and read the docs again or ask around - the library in general takes care of everything it should and gets out of the way really well o…
Debouncing (for interactive form validations) seems to be something that you still have to sort out yourself.
And I'm not sure how much work the mutation support saves in practice (compared to the extremely sophisticated Apollo cache).
Re: TanStack Query(a.k.a. React Query) v5 announced
#57My react applications cache nothing and don’t use global state except to put the user Id in localstorage. No redux, no context, no network cache, no nothing. Minimal props. I just use custom events to tell the rest of the application what to. And use fetch to get stuff. Does away with all the complexity of state management or prop drilling.
Not gonna lie: that sounds absolutely awful, and I can't imagine this works at any real scale. It will also have poor UX, because your users will be waiting for data which you already fetched and should just have cached. There are also plenty of applications where what you are describing is arguably just not feasible at all, like heavier applications that due to their nature just need a lot of client-side state.
I'd personally still favor Next.js + TanStack Query if given the choice.
Re: TanStack Query(a.k.a. React Query) v5 announced
#58My react applications cache nothing and don’t use global state except to put the user Id in localstorage. No redux, no context, no network cache, no nothing. Minimal props. I just use custom events to tell the rest of the application what to. And use fetch to get stuff. Does away with all the complexity of state management or prop drilling.
Re: TanStack Query(a.k.a. React Query) v5 announced
#59Earlier quoted context omitted.
What don't you like about Apollo? I've used both apollo (for graphql backends) and react query (for rest backends) and find them quite similar.
Writing your own backend for GraphQL doesn't scale. You should stick to no-code solutions that can auto generate graphQL on top of existing APIs. Checkout https://tailcall.run
Re: TanStack Query(a.k.a. React Query) v5 announced
#60It’s worth noting you can autogenerate TanStack Query clients in a typesafe way using graphql-codegen, really saves a lot of time!
wait really? do you have a link I can check out?