Hive Console Documentation

repository·main·Indexed 19 days ago

https://github.com/graphql-hive/console

An open-source schema registry and analytics platform for GraphQL federation and standalone APIs. Includes documentation for the Hive CLI, schema management (publish, check, promote, fetch), app deployment, and integration with Apollo and Grafana monitoring.

Tokens
80.5K
Snippets
225
Records
301
Agent score
67%

What's inside Hive Console

  1. Overview of Hive Console features

    main

    Hive Console provides several key capabilities for managing GraphQL APIs:

    • Schema Registry: Prevents breaking changes through automated checks, provides a full history of changes (including for Federation and Stitching), and uses data-driven definitions of breaking changes based on operations monitoring.
    • Monitoring: Provides visibility into error rates, latency, request volume, operation counts, and active GraphQL clients.
    • OpenTelemetry Tracing: Allows inspection of distributed GraphQL traces, capturing spans, HTTP/client metadata, and federation subgraph activity.
    • App Deployments (Persisted Documents): Enables publishing versioned persisted-document artifacts and safely activating/retiring deployments via CDN.
    • Integrations: Supports Slack, Microsoft Teams, and custom webhooks for alerts. It also integrates with GitHub to add status checks to pull requests.
  2. Overview of `@hive/commerce` service

    main

    The @hive/commerce service provides the commerce backend for Hive. Its primary responsibilities include:

    • Usage estimation
    • Rate-limit lookups
    • Stripe billing

    It exposes a tRPC router named commerceRouter (located in src/api.ts). This router is intended to be consumed by the server and usage services by configuring the COMMERCE_ENDPOINT environment variable.

  3. Overview of `@hive/usage` service

    main

    The @hive/usage service is responsible for handling HTTP requests for usage reporting. It acts as an ingestion point for usage data, which is then processed through a pipeline:

    1. HTTP requests are received by @hive/usage.
    2. Data is written to a Kafka broker.
    3. The usage-ingestor service consumes data from Kafka and feeds it into ClickHouse.
  4. Federation composition validation rules (v0.54.0)

    main

    Version 0.54.0 introduced several enhanced validation rules for Federation composition via federation-composition v0.21.0:

    • Auth Directive Placement: Enforces correct placement of @authenticated, @requiresScopes, and @policy. These cannot be placed on interfaces, interface fields, or interface objects (AUTH_REQUIREMENTS_APPLIED_ON_INTERFACE).
    • Transitive Auth Requirements: Ensures fields using @requires specify at least the auth requirements of the fields they select. Failure results in a MISSING_TRANSITIVE_AUTH_REQUIREMENTS error.
    • Auth Inheritance: Interface types and fields properly inherit @authenticated, @requiresScopes, and @policy directives from implementing object types.
    • @cost Directive Restrictions: The @cost directive is restricted from being placed on interface types, their fields, or field arguments.
    • @listSize Validation: Validates that sizedFields point to actual list fields and ensures slicingArguments only include arguments present in all subgraphs.
    • EXTERNAL_MISSING_ON_BASE: Fixed false positives for @interfaceObject corner-cases involving @external fields.
  5. How `@hive/schema` handles composition requests

    main

    The @hive/schema service handles incoming composition requests via HTTP (tRPC) using a multi-layered approach to optimize performance and stability:

    1. Caching: The service first checks Redis for a cached result to avoid redundant computation.
    2. Task Deduplication: If not cached, the TaskManager checks if the specific composition task is already in progress. If so, the request waits for the existing task to complete rather than starting a new one.
    3. Worker Pool Execution: If no task is in progress, the task is assigned to a WorkerPool. Each task runs in an isolated worker thread with memory limits to ensure that a single malfunctioning task does not crash the entire service.
    4. Queueing: If all workers in the pool are busy, tasks are enqueued in memory until a worker becomes available.
    5. Result Persistence: Once a task completes, the result is cached in Redis and returned to all pending requests.
  6. Guidelines for database migrations

    main

    When working with @hive/migrations, follow these best practices to ensure database integrity:

    • Immutability: Never delete previous migration files. Once a migration is merged to the main branch, do not change its code or filename.
    • Reversibility: Every migration that changes the database structure must have a down migration that performs the exact opposite operation, typically in reverse order.
    • Performance: Migrations should be lightweight. If a migration performs too many tasks, break it into smaller pieces.
    • Production Awareness: Be aware that migrations running on production will encounter significantly more data than in development; a migration that is fast locally may take a long time in production.
  7. Protect app deployments from accidental retirement

    main

    Introduced in version 0.58.0, Hive supports app deployment retirement protection settings. When enabled, these settings prevent the retirement of app deployments that meet certain criteria, such as:

    • Recent creation age
    • Active usage within a configurable inactivity period
    • Specific traffic thresholds
  8. Understand Integration Test Docker Compose configuration

    main

    Integration tests utilize a combination of two Docker Compose files to simulate a complete Hive Cloud environment:

    1. docker-compose.community.yml: Contains all services and configurations required to run Hive core (excluding Cloud-specific services like billing). This is the same file used for self-hosting.
    2. docker-compose.integration.yaml: An extension/override file used to run mocks for services like the CloudFlare CDN mock and external composition service.

    Warning: docker-compose.integration.yaml includes environment variable overrides specific to integration testing. Use caution when adding environment variables that might be affected by these overrides.