Alternatively, you can also provide the usage reporting configuration via the gateway.config.ts
file.
gateway.config.ts
import { defineConfig } from '@graphql-hive/gateway'export const gatewayConfig = defineConfig({ reporting: { type: 'hive', // The registry token provided by Hive Registry, defaulting to process.env.HIVE_USAGE_ACCESS_TOKEN token: '<token>' // The registry target which the usage data should be reported to defaulting to process.env.HIVE_USAGE_TARGET // This can either be a slug following the format `$organizationSlug/$projectSlug/$targetSlug` (e.g `the-guild/graphql-hive/staging`) // or an UUID (e.g. `a0f4c605-6541-4350-8cfe-b31f21a4bf80`). target: '<target>' /** * Other options * * selfHosting: { ... }, * clientInfo(context) { ... }, * * See more in Hive Client reference */ }})
If you want to control the usage reporting to the Hive Console like selfHosting, clientInfo etc,
please look at the Hive Client documentation to learn more about other options.
See more in Hive Client reference
If you want to report usage metrics to a Apollo GraphOS, configure your gateway.config.ts file as
following.
gateway.config.ts
import { defineConfig } from "@graphql-hive/gateway";export const gatewayConfig = defineConfig({ reporting: { type: "graphos", /** * The graph ref of the managed federation graph. * It is composed of the graph ID and the variant (`<YOUR_GRAPH_ID>@<VARIANT>`). * * If not provided, `APOLLO_GRAPH_REF` environment variable is used. * * You can find a a graph's ref at the top of its Schema Reference page in Apollo Studio. */ graphRef: "<graph_id>[@<variant>]", /** * The API key to use to authenticate with the managed federation up link. * It needs at least the `service:read` permission. * * If not provided, `APOLLO_KEY` environment variable will be used instead. * * [Learn how to create an API key](https://www.apollographql.com/docs/federation/v1/managed-federation/setup#4-connect-the-gateway-to-studio) */ apiKey: "<api_key>", /** * Usage report endpoint * * Defaults to GraphOS endpoint (https://usage-reporting.api.apollographql.com/api/ingress/traces) */ endpoint: "https://usage-reporting.api.apollographql.com/api/ingress/traces", /** * Agent Version to report to the usage reporting API * * Defaults to the Hive Gateway's version */ agentVersion: "hive-gateway@1.0.0", /** * Client name to report to the usage reporting API * * Defaults to incoming `apollo-graphql-client-name` HTTP header */ clientName: (req) => req.headers.get("apollo-graphql-client-name"), /** * Client version to report to the usage reporting API * * Defaults to incoming `apollo-graphql-client-version` HTTP header */ clientVersion: (req) => req.headers.get("apollo-graphql-client-version"), },});
This site uses cookies for analytics and improving your experience.