Comments (5)
That one which is directly on the client makes more sense to me as for reporting to Sentry.
Although most of the GraphQL errors are to be handled by the app in the UI. You should catch the others (errors or bugs) in the server side (e.g. Apollo Server) and only pass the errors which are for the users to the client.
The way I might be handling this is to use ConnectHOC
and check for error in the componentWillRecieveProps
which is not the best practice, especially now that it is deprecated I should use the new hook.
from urql.
@morajabi i want to handle error in component but also want to have associated side effects for the corresponding error. For eg, if the page listing todo's has error, then push pack to home page or maybe 500 page.
And yes, errors like these should be handled on server-side (in an ideal world), but there are times, when server side has uncaught bugs and i want to gracefully handle them on ui.
Currently i am using getDerivedStateFromProps
(componentWillRecieveProps
has been / is getting depreciated) to check in the child component of Query if there was error or not, but for this i have to always use a class component as a child of query.
The other approach is to throw an error and catching it in componentDidCatch
, enabling me to use stateless components to render result of Query
.
from urql.
I'm not pointing at Redux, as I didn't mention and don't use Redux. Urql exports a ConnectHOC
which is a HoC.
I said handling uncought errors with Sentry is supposed to be done on the server side. So you just need to show an error screen in the UI. So you can gracefully handle them in UI, I think you're not quite used to the render props pattern yet, maybe.
<Connect>
{({ error }) => {
if (error) {
return <ErrorScreen error={error} />
}
// ...
}}
</Connect>
This is quite like how React apps should be architectured.
Throwing an error makes total sense as well, and I think it is there for situations like this, but most of the time it is not necessary.
from urql.
@morajabi ahh sorry i miss read about Connect
😅 . my problem is I don't want to display error, i want to change route (for eg).
Also backend team doesn't use sentry and i do want to use it for failing queries.
PS: Don't mind but, I don't feel there is a single way of how react apps should be architectured, in my app i would like to re route user on error and see nothing wrong in that
from urql.
i am sticking to throwing errors and catching the , thus closing the issue
from urql.
Related Issues (20)
- useQuery in Nextjs Client Component should be executed from the client side HOT 3
- Passing a `Headers` object results in an error
- Possible memory leak when using multiple queries on the same page HOT 7
- requestPolicyExchange does not re-request in production HOT 3
- cacheExchange - cache.readQuery (updateQuery) can't find queries with aliased variables HOT 1
- @urql/exchange-persisted Module name, 'crypto' does not resolve to a valid URL. HOT 7
- Non RSC authExchange failing HOT 2
- Problem: @urql/exchange-graphcache updateCacheWithResult reads null after writing link in cache updater. HOT 8
- Invalidating cache in Graphcache doesn't trigger query refetch in Next.js app router HOT 2
- RFC: react native file upload support HOT 1
- Introspected schema from urql-introspection doesn't match type of exchange-graphcache HOT 1
- RFC: Graphcache strong typing HOT 3
- Graphcache: mutations with different files in parallel, results lost HOT 2
- Invalidate with a key does not produce expected result HOT 2
- RFC: Normalize embedded documents based on parent HOT 5
- Syntax Error: Unexpected token in SelectionSet HOT 1
- RFC: @urql/vue - Allow getter syntax in `useQuery` HOT 4
- RFC: Add secondary keys HOT 2
- @urql/exchange-graphcache returns empty data & error although fetch response contains valid data. (when same entity is requested in parallel) HOT 1
- Multiple requests when using react suspense HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urql.