graphql-hive / graphql-hive/console

Incorrect operation body shown in Insights

Open
#8,161 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
483
Forks
145
Avg merge
2d 5h
Merged PRs (30d)
65

Description

Hi, we have set up usage data/insights sending from Hive Router to the Hive Console, but we have encountered issues with the operation body being incorrect.
It seems that when we send a GraphQL document containing more than one operation and select a specific one (non-first) using `operationName`, it always shows the first query body regardless of what `operationName` contains.

I tried the same setup with the Hive Gateway, but it seems to be producing the same (invalid) results.

Minimal reproduction:
1) Create a new project in Console and generate required tokens (1x for registry, 1x for hive telemetry)
2) Download the official SWAPI schema from https://github.com/graphql/swapi-graphql/blob/master/schema.graphql
3) Configure `supergraph.yaml` with
```yaml
federation_version: =2.3.2
subgraphs:
swapi:
routing_url: https://graphql.org/graphql/
schema:
file: ./schema.graphql
```
4) `rover supergraph compose --config ./supergraph.yaml > supergraph.graphql`
5) `hive schema:publish --target "..." --registry.accessToken "..." --author "Test" --commit "test" ./supergraph.graphql`
6) Configure Router's `router.config.yaml` with
```yaml
supergraph:
source: file
path: ./supergraph.graphql
telemetry:
hive:
token: ...
target: ...
usage_reporting:
enabled: true
tracing:
enabled: true
```
7) Run the Router
`docker run -p 4000:4000 -v ./supergraph.graphql:/app/supergraph.graphql -v ./router.config.yaml:/app/router.config.yaml ghcr.io/graphql-hive/router:latest`
8) Send a query containing at least two operations and select the non-first one in `operationName`
```bash
curl 'http://localhost:4000/graphql' \
-H 'accept: application/graphql-response+json, application/json, multipart/mixed' \
-H 'content-type: application/json' \
--data-raw '{"query":"query first{__typename} query second{allFilms{totalCount}}","operationName":"second"}'
```
9) Observe "Insights" in the Console application showing the first operation body in the `second` operations/traces.

Note that this is not reproducible using the Web IDE bundled with Router as it always only sends the part of the body relevant to the selected operation instead of the whole document.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the Router configuration and curl request in the report, then trace how Insights displays usage data for the selected operationName. Compare the Console result with the Web IDE behavior and verify that the displayed operation body matches the selected non-first operation when the fix is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
analytics, api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.