-
Notifications
You must be signed in to change notification settings - Fork 974
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
Show beautiful GraphQL error messages #484
Comments
The GraphQL spec says that all errors part of the The The spec allows GraphQL servers to provide extra keys with the error, for example the GitHub API includes Another note, keep in mind it's very much possible to receive multiple errors for a given query. For example, imagine you request two fields the integration doesn't have access to. Let me know if there's anything else I can shed light on. 😄 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
And also looking back at the spec that was linked above:
So per the spec, errors can still be present even when partial data is returned. On the client side (Apollo, Relay), they recommend looking at error types and only presenting ones in the UI that make sense to display to the user. I think it would make sense here to just use
Testing this locally, I get Example: {
"data": {
"resource": {
"title": "Radar: Weekly Planning for 2018-05-13",
"createdAt": "2018-05-13T01:00:34Z",
}
},
"errors": [
{
"message": "Resource protected by organization SAML enforcement. You must grant your personal token access to this organization.",
"type": "FORBIDDEN",
"path": [
"resource",
"comments",
"edges",
0,
"node"
],
"locations": [
{
"line": 10,
"column": 11
}
]
}
]
} Pushing the errors up into the client could be accomplished by only returning const { data, errors } = await context.github.query(getResource, {
url: context.payload.issue.html_url
})
if (errors) { context.log.error({ errors }) }
const { resource } = data It doesn't feel that awesome, but since the errors have types that need to be handled based on the needs of the app, I think we have to push the errors up into the client. |
I agree |
Given the constraints we're working with it feels like |
the graphql error messages are much more useful now that we use |
GraphQL returns great error messages:
We should take advantage of that and make them B-E-A-utiful!
We need to get a full spec on what all the GraphQL errors will include, but here's some thoughts:
locations
is included, then show the original query with a pointer to exactly where the error occurredcc @cjoudrey @tcbyrd
The text was updated successfully, but these errors were encountered: