Comments (4)
Hi Radoslav - sorry about the delay!
I think it is really important that all server implementations in howtographql use the same schema so al frontend examples can be compatible.
For that reason I would be in favour of not modeling errors in the response data.
You mention that the graphql build-in errors are hard to handle on the client side. I would like to better understand why you think so. This is how we handle all errors for our main app, console.graph.cool and this is also how we tell our customers to handle errors (https://www.graph.cool/docs/reference/simple-api/error-management-aecou7haj9/)
I am aware that Apollo currently has very poor support for graphql build-in errors. I'm hoping we can help them fix that asap: apollographql/apollo-client#51 (comment)
ps, I have a good friend who used to work on nativescript at Telerik before moving to Copenhagen. Maybe you know him?
from howtographql.
Hi @sorenbs
All implementation should definitely be the same. I'll do what everybody agrees.
My personal preferences is to have validation errors in errors
field and not use the schema. I had quite good success with that approach.
For one having multiple validation errors returns as schema errors is badly supported by Apollo, Elixir's Absine and Ruby gem. (Ruby gem advices agains them)
Which would lead to problems if we want to handle the following situation:
createLink ->
- too short description
- invalid url
On the other side having errors
with Error
type gives you:
- more control about the response
- easier to handle in frontend (in forms especially)
- you have clear separation between errors caused by a user and system errors.
The way I handle almost all of my forms is something like:
// `submit` is apollo mutation, `params` is data from form
const { data: { errors, node } } = await this.props.submit(params);
// if there are errors, then just add errors to form state
// ...and you are done
if (errors.length> 0) {
this.setState({ isSubmitting: false, errors });
} else {
// on success just pass the node
this.setState({ isSubmitting: true });
this.props.onSuccess(node);
}
I'm actually not very sure how to handle this, with schema errors. I suspect something with try/catch.
But again, what ever is decided, I would go with it.
p.s. I know couple of people from Telerik NativeScript from Sofia. What is your friend's name?
from howtographql.
Thanks - let's keep the original schema then.
The error handling pattern you showed is very compelling. Apollo is currently reimplementing their error handling logic (linked above). If you have the time, it would be really nice if you could present this pattern to them and start a conversation about how to enable the same convenience when using schema errors.
It's a small world :-) My friend is Yavor Georgiev.
from howtographql.
👍 I'll work with the current schema
from howtographql.
Related Issues (20)
- Route exact in "react-router-dom" seems to be depracated
- gopls.go_get_package has failed on go-graphql-hackernews... HOT 1
- New tuto in Typescript react for frontend with apollo client ? HOT 3
- Unable to achieve completion chapters on Ruby tutorial
- Dark mode(Theme options) will be good for UX and DX HOT 2
- [howtographql/content/frontend/react-apollo/6-more-mutations-and-updating-the-store.md] - Link's index is undefined in lesson
- apollo-node tutorial uses version 2 of apollo-server which is no longer available HOT 1
- Typo in the Authentication section HOT 2
- problem in authentication
- Logged in User tutorial does not work HOT 2
- server.go failed to compile in golang examples
- Pagination in React/Apollo doesn't work correctly. HOT 2
- Updating Store - Guide needs an update HOT 1
- Prisma, NextJs, Issue with nested query with nested where Provided Json, expected Int.
- (node:8616) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated. HOT 1
- Go Tutorial it's broken HOT 1
- Python tutorial with Strawberry HOT 11
- upgrade tutorial to apollo v4
- React + Apollo Tutorial- Mutations:Creating Links
- Incorrect Code in Documentation HOT 1
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 howtographql.