connectrpc / connect-query-es

TypeScript-first expansion pack for TanStack Query that gives you Protobuf superpowers.

Home Page:https://connectrpc.com/docs/web/query/getting-started

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set `QueryObserverOptions`?

cherewaty opened this issue · comments

I end up customizing refetchInterval per query pretty often with Tanstack Query's useQuery. On some pages, I want rapid 1-second polls of a specific unary call, and on others just once a minute or so.

Is there a mechanism for setting any of the QueryObserverOptions, like refetchInterval, with a useQuery generated from @bufbuild/connect-query?

This doesn't appear to work at the moment, but should the full array of Tanstack Query's useQuery options (https://tanstack.com/query/v4/docs/react/reference/useQuery) be available to UnaryHooks.useQuery.options?

const { data: things } = useQuery(getThings.useQuery({}, { refetchInterval: 1000 }));

hi @cherewaty: take a look at https://github.com/bufbuild/connect-query#how-do-i-pass-other-tanstack-query-options

I believe this does what you want, but if not, please let me know and we can reopen and dig deeper!

I applied the documented pattern, and it's working great. Thanks for the FAQ addition!

that's great! let us know how you like connect-query and if there's anything you'd like it to do better! the Buf Slack is a great place to informally drop us a line!