From 82e1eeb3a5d216b4a6d5dd0cc6668bfd1d72e390 Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Tue, 6 Sep 2022 18:09:19 +0200 Subject: [PATCH] docs: add metadata to the example payload and a curl example command (#340) --- .../web/docs/pages/specs/usage-reports.md | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/web/docs/pages/specs/usage-reports.md b/packages/web/docs/pages/specs/usage-reports.md index 810c3a27b..46830f425 100644 --- a/packages/web/docs/pages/specs/usage-reports.md +++ b/packages/web/docs/pages/specs/usage-reports.md @@ -11,7 +11,7 @@ The official JavaScript Hive Client (`@graphql-hive/client`) collects executed o | Header | `X-API-Token: token-here` | | Method | `POST` | -**Data structure** +## Data structure
TypeScript schema @@ -210,7 +210,7 @@ export interface Client {
-**Example** +## Raw JSON Example Payload ```json { @@ -235,6 +235,12 @@ export interface Client { "ok": true, "duration": 150000000, // 150ms in nanoseconds "errorsTotal": 0 + }, + "metadata": { + "client": { + "name": "demo", + "version": "0.0.1" + } } }, { @@ -244,6 +250,12 @@ export interface Client { "ok": false, // failed operation "duration": 150000000, // 150ms in nanoseconds "errorsTotal": 1 // 1 GraphQL error + }, + "metadata": { + "client": { + "name": "demo", + "version": "0.0.1" + } } }, { @@ -253,8 +265,24 @@ export interface Client { "ok": true, "duration": 150000000, // 150ms in nanoseconds "errorsTotal": 0 + }, + "metadata": { + "client": { + "name": "demo", + "version": "0.0.1" + } } } ] } ``` + +## Curl example request + +```bash +curl -X POST \ + https://app.graphql-hive.com/usage \ + -H 'x-api-token: token-here' \ + -H 'content-type: application/json' \ + -d '{ "size": 1, "map": { "aaa": { "operationName": "me", "operation": "query me { me { id } }", "fields": ["Query", "Query.me", "User", "User.id"] } }, "operations": [{ "operationMapKey" : "c3b6d9b0", "timestamp" : 1655112281535, "execution" : { "ok" : true, "duration" : 150000000, "errorsTotal" : 0 }, "metadata" : { "client" : { "name" : "demo" , "version" : "0.0.1" } } } ] }' +```