-
Notifications
You must be signed in to change notification settings - Fork 859
Error sources #2199
Comments
@timsuchanek i'd be happy to work on this. Feeling the pain right now trying to debug missing sub selection errors and something like your proposal would be very helpful. |
Extending the original proposal, what we essentially want to do is to recursively preserve the This can be achieved by adding
An example response of graphql server implementing such a sources solution would look like this: {
"errors": [
{
"message": "Name for character with ID 1002 could not be fetched.",
"locations": [{"line": 6, "column": 7}],
"path": ["hero", "heroFriends", 1, "name"],
"extensions": {
"schemaId": "schema_1",
"code": "CAN_NOT_FETCH_BY_ID",
"timestamp": "Fri Feb 9 14:33:09 UTC 2018",
"delegationErrors": [
{
"message": "Name for character with ID 1002 could not be fetched.",
"locations": [{"line": 6, "column": 7}],
"path": ["hero", "heroFriends", 1, "name"],
"extensions": {
"schemaId": "schema_2",
"code": "CAN_NOT_FETCH_BY_ID",
"timestamp": "Fri Feb 9 14:33:09 UTC 2018"
}
}
]
}
}
]
}
|
I'm having a hard time dealing with my errors from Prisma as they aren't machine readable. Please fill the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions. |
Motivating the Problem
Let's say you're writing an application with the common Yoga/Binding/Prisma stack:
This has many benefits as better flexibility and less code, but makes locating GraphQL Errors right now pretty hard. That's the case, because in this stack we have 3 GraphQL Schemas that are involved to process a query.
GraphQLSchema
from graphql js.Where did the error happen?
Let's say we get a response like this: (taken from prisma-labs/graphql-prisma-typescript#92)
We now know that a subselection is missing. We suspect this error to occur in either the Yoga schema or the binding schema. But where did it actually happen? We don't know.
This is a simple example, where only one source is used in Yoga. There could be hundreds of microservices used by Yoga, where the overview would be totally lost. We need a solution for this.
Proposal
In order to know where an error comes from, we could add a property to it, that describes its source.
Right now the spec for the error type looks like this:
In Prisma we added 2 more properties,
requestId
andcode
:The proposal is, too add a property called
source: String
. In our example from above, it would look like this:Now we can see, that the error has been triggered in the yoga schema.
Moving forward
This is a rough proposal, how a solution for finding the error source could look like.
If you're interested in working on this, please let us know in a comment or join our public Graphcool Slack!
The text was updated successfully, but these errors were encountered: