urql: Handling errors when using suspense-mode on the client-side

Hi! We are trying out urql now that suspense has landed.

I’m trying to rework our old error handling for queries, but it seems errors are never passed on from the useQuery hook, at least when using suspense. Instead the request is retried perpetually.

const [result] = useQuery({ query });
// never reaches beyond this point
if (result.error) throw new Error(result.error);

Is it possible to disable the retry policy and grab the error?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (19 by maintainers)

Most upvoted comments

Documentation for Wonka and guides on how to write exchanges are coming soon 👍

I just quickly wrote a suspenseExchange that should work for you. Sorry for the delay! https://gist.github.com/kitten/f34b50b2782476e6aabb0ebd359d5862

I haven’t tested it, but it should work well for client-side suspense. It caches a response once so that when suspense has finished waiting it can get the response once from the cached responses.

So this doesn’t duplicate or replace the cacheExchange, so that the cache still works as expected.

https://gist.github.com/kitten/f34b50b2782476e6aabb0ebd359d5862