exotic-emerald
exotic-emerald6mo ago

when I make request with any hook, the request is sent three times before showing the error message.

How can I make to just send one request before handling the error?
2 Replies
kapa.ai
kapa.ai6mo ago
Hi @Jaoc1811. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In refine, the number of times a request is retried before showing an error message is controlled by the retry option in the queryOptions property of hooks. By default, refine uses React Query for data fetching, which retries failed queries a few times before marking them as an error. If you want to disable retries and make it so that only one request is sent before handling the error, you can set the retry option to false. You can do this for each hook individually, like so:
useList({ resource: 'posts', queryOptions: { retry: false } })
useCreate({ resource: 'posts', queryOptions: { retry: false } })
useTable({ resource: 'posts', queryOptions: { retry: false } })
useForm({ resource: 'posts', queryOptions: { retry: false } })
useList({ resource: 'posts', queryOptions: { retry: false } })
useCreate({ resource: 'posts', queryOptions: { retry: false } })
useTable({ resource: 'posts', queryOptions: { retry: false } })
useForm({ resource: 'posts', queryOptions: { retry: false } })
If you want to disable retries globally for all queries, you can do so in the ReactQueryClientConfig section of the refineConfig:
<Refine config={{ ReactQueryClientConfig: { queries: { retry: false } } }}>
<Refine config={{ ReactQueryClientConfig: { queries: { retry: false } } }}>
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 refineConfig (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) - Documentation > Docs > Guides-concepts > Data Fetching > Fetching Data > Code Files Part 2 (https://refine.dev/docs/guides-concepts/data-fetching#fetching-data) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@110864105035808768> kapa.ai is still learning and improving, please let us know how it did by reacting below