Disable batching multiple useQuery
I'm using useQuery as below:
I've noticed that upon loading the component the above produces one network request with both the queries in one, i.e:
In my case the
getHistorical
query makes an external API call which sometimes takes quite long to complete and as a result data
from getByCode
will be delayed because getHistorical
is taking so long.
I came across this tRPC documentation:
https://trpc.io/docs/v9/links#using-a-splitlink-to-control-request-flow
And tried following along by amending my src/utils/api.ts
file:
And tried using it in my component query like so:
But I'm currently getting an error in VSCode (see attached image).
Or am I completely on the wrong path and there is a simpler way of not batching queries?Links & Request Batching | tRPC
Similar to urql's exchanges or Apollo's links. Links enables you to customize the flow of data between tRPC Client and the tRPC-server.
0 Replies