graphql-hive / graphql-hive/console

Break down errors by extension codes

Open
#6,381 1 comment 2 reactions 0 assignees View on GitHub
improvement insights usage reports
Dominant language
TypeScript
Stars
483
Forks
145
Avg merge
2d 5h
Merged PRs (30d)
65

Description

## Background

We gather information about GraphQL requests that contain an error response (`errors` key is present within the GraphQL response).
This information is used to display the success and failure rate of GeaphQL request within the Hive Console dashboard, insight view.

**Total failure rate**

![Image](https://uploads.linear.app/d27962ec-fde7-415f-a81c-8d2bc5a7ff94/9c47a859-2b3d-41ee-a229-23f4417ec020/0241818f-e29d-455c-98b3-d369df9db474?signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXRoIjoiL2QyNzk2MmVjLWZkZTctNDE1Zi1hODFjLThkMmJjNWE3ZmY5NC85YzQ3YTg1OS0yYjNkLTQxZWUtYTIyOS0yM2Y0NDE3ZWMwMjAvMDI0MTgxOGYtZTI5ZC00NTVjLTk4YjMtZDM2OWRmOWRiNDc0IiwiaWF0IjoxNzc2MDg1ODQ5LCJleHAiOjE4MDc2NTY0MDl9.1ygGiBYKxASGlYA3Y_U498RjZoOSNWuD81D6FJZIPkE)

**Failure rate compared to success rate**

![Image](https://uploads.linear.app/d27962ec-fde7-415f-a81c-8d2bc5a7ff94/6cc4abb9-9259-4feb-9b52-1b1782d665e1/b669f319-c7bc-461c-b4f4-8bf2ea545bcc?signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXRoIjoiL2QyNzk2MmVjLWZkZTctNDE1Zi1hODFjLThkMmJjNWE3ZmY5NC82Y2M0YWJiOS05MjU5LTRmZWItOWI1Mi0xYjE3ODJkNjY1ZTEvYjY2OWYzMTktYzdiYy00NjFjLWI0ZjQtOGJmMmVhNTQ1YmNjIiwiaWF0IjoxNzc2MDg1ODQ5LCJleHAiOjE4MDc2NTY0MDl9.9nJi4L-M2e7PUVJ4KUUMRQ5Rmh94CCTM_TbYxQasv00)

**Failure rate by operation**

![Image](https://uploads.linear.app/d27962ec-fde7-415f-a81c-8d2bc5a7ff94/04ffc062-4dd7-44ad-89ea-e628e53ce22c/5882e7e4-b1f5-4259-9f8c-2996986fa4bb?signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXRoIjoiL2QyNzk2MmVjLWZkZTctNDE1Zi1hODFjLThkMmJjNWE3ZmY5NC8wNGZmYzA2Mi00ZGQ3LTQ0YWQtODllYS1lNjI4ZTUzY2UyMmMvNTg4MmU3ZTQtYjFmNS00MjU5LTlmOGMtMjk5Njk4NmZhNGJiIiwiaWF0IjoxNzc2MDg1ODQ5LCJleHAiOjE4MDc2NTY0MDl9.sFoBWKRZNWURHfRiuXkdh64YEHIruhriiLjeM0sGhIc)

---

A common practice is to use the `code` property within the error extensions to identify the origin of the error.

E.g. if a access token sent to a GraphQL API is expired, the following response could be interpreted by the frontend client for refreshing the access token.

```json
{
"errors": [
{
"message": "AccessToken expired",
"extensions": { "code": "NEEDS_REFRESH" }
}
]
}
```

Or if a request was made without an access token, the following response could be interpreted by the frontend client for showing a log-in form.

```json
{
"errors": [
{
"message": "AccessToken expired",
"extensions": { "code": "UNAUTHENTICATED" }
}
]
}
```

Apollo Server initially popularized this pattern and has become an unofficial standard for handling arbitrary errors that are not defined using the Schema SDL.

---

## Task Overview

Users of Hive want to see the reason the reason on why the execution of a request failed without using additional tools. An enhancement would be to include the error code(s) within the usage reporting.

The following things need to be done:

1. Adjust usage service to support sending error codes to the usage reporting API for the v2 protocol
2. Adjust the Hive SDKs for extracting the error codes from an error response and include them in the JSON payload sent to the usage reporting API (also include a way to customize the extraction of the error codes; sending error codes **should be** opt-in)
3. Figure out how to store the error code data within our Clickhouse database
4. Figure out how to display the information within the hive insights dashboard

* Breakdown of all error codes
* Breakdown of error codes per operation within the operation details view

## Links

* [Original message]():

> I was wondering if there was a good way in HIVE insights tab to break the errors down by “extensions.code” attached to the error object.
* [Apollo Server error codes]()
* [Using error codes for doing authentication refresh on client]()
* [Hive usage reporting specification]()

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.