How can one disable retry on failed queries ?
I have a valid case of checking if entity is present, the api responds with 404 as it should and I need to adjust the UI. In current default behavior, the 404 is retried, but it should not retry as 404 is expected.
5 Replies
Hi @i.stoica. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
You can disable retry on failed queries by setting the
retry
option to false
in the queryOptions
property of hooks like useList
, useCreate
, useTable
, useForm
, etc. Here's an example:
If you want to disable retries globally, you can do so in the reactQueryClientConfig
prop of the <Refine>
component. Here's an example:
You can also set custom retry logic. For example, you can disable retries when the status code is 404:
For more information, you can refer to the React Query documentation on query retries (https://react-query.tanstack.com/guides/query-retries#_top) and the Refine documentation on the Refine component (https://refine.dev/docs/core/components/refine-config/#reactqueryclientconfig).
Sources:
- Github Issue (closed): [BUG] @pankod/refine-nhost is not handling graphQL error responses > Comments Part 4 (https://github.com/refinedev/refine/issues/1794)
- Github Issue (closed): [BUG] @pankod/refine-nhost is not handling graphQL error responses > Comments Part 6 (https://github.com/refinedev/refine/issues/1794)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@180601470268211200> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold•8mo ago
Refine
component has no such reactQueryClientConfig
option
The queryOptions
retry: false
in useShow
is not respected, I still see the query being performed twice.rival-black•8mo ago
Hello @i.stoica
- you can change client config like this https://example.admin.refine.dev/orders/show/1
- it's performed twice probably because of this https://example.admin.refine.dev/orders/show/1
Finefoods Ant Design Admin Panel - refine
Web site created using refine
stormy-gold•8mo ago
Thank you @Alican Erdurmaz