Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex Errors #90

Closed
jacklaaa89 opened this issue Apr 23, 2018 · 2 comments · Fixed by #95
Closed

Complex Errors #90

jacklaaa89 opened this issue Apr 23, 2018 · 2 comments · Fixed by #95

Comments

@jacklaaa89
Copy link

jacklaaa89 commented Apr 23, 2018

How would we represent complex error types using this library. We currently only have a single error message for each error found performing a request. However how can a UI component utilise this effectively. For example say we have a query which requires some kind of authorisation. How can we return this in the UI. More importantly how we give some context of the type of error? i.e in the authorisation problem, the UI should react differently to session timeout errors over not authorised to access a resource. So I think that:

{ "data": null, "errors": [ { "message": "token expired" } ] }

is not enough context or detail to be able to react appropriately as there will be a lot of string parsing. Could we not add an additional field to the errors given with some extra metadata about that error, i.e at least an error code or something more static around a particular error in the system.

Even making the returned error an interface we can implement ourselves would be better. The apollo client GraphQLError returned also seems to have a field called extraInfo even if we could populate that with additional context.

@vektah
Copy link
Collaborator

vektah commented Apr 24, 2018

The error handling is ready for a refactor. There was some work initially done in #45 to get customizable user messages and panic handlers.

Maybe its enough for errors to implement the json marshaler interface?

@jacklaaa89
Copy link
Author

Yeah that would be the perfect outcome, then we can marshal any custom information into errors when they are returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants