WunderGraph Cosmo

website·Indexed 37 days ago

https://docs.wundergraph.com/

A robust and scalable platform for managing federated GraphQL graphs and gRPC services. The documentation covers the Cosmo Platform architecture and the wgc CLI for managing namespaces, federated graphs, feature flags, feature subgraphs, and GraphQL clients.

Tokens
199.7K
Snippets
881
Records
1.4K
Agent score
58%

What's inside Cosmo

  1. Overview of the SubscriptionOnCreate Handler

    The SubscriptionOnCreate handler is an experimental custom module hook that runs once per subscription before it is registered with the message broker. It allows developers to modify the subscription event configuration in place. This is primarily used for dynamic subject routing (NATS, Redis, Kafka) or overriding provider-level defaults on a per-request basis.

    Limitations:

    • It cannot emit events to the client.
    • It only applies to Cosmo Streams / EDFS subscriptions, not regular GraphQL subscriptions.
  2. Overview of WunderGraph Cosmo Schema Contracts

    Schema Contracts allow you to create a filtered version of a Source Graph (either a federated graph or a monograph) to build versatile, multi-audience APIs. This prevents the creation of monolithic graphs and enables tailored experiences for specific user groups, improved data security by filtering sensitive information, and easier onboarding for developers by reducing schema complexity. They can also serve as a compatibility layer for legacy system integration or provide isolated views for multi-tenant applications.
  3. Overview of Persisted Operations

    Persisted operations (also known as trusted documents) allow developers to register GraphQL queries, mutations, and subscriptions in the router ahead of time. This enables clients to send only a unique identifier (SHA-256 hash) instead of the full operation body, reducing bandwidth and limiting the attack surface by only allowing safe-listed operations.
  4. Overview of Router Metrics and Monitoring

    The router provides built-in support for OpenTelemetry (OTEL) and Prometheus to export R.E.D. (Rate, Errors, Duration) metrics for incoming GraphQL traffic. OTEL metrics serve as the foundation for both; however, asynchronous instruments are not exposed via Prometheus. In Prometheus, metrics use snake_case and specific suffixes. By default, OTEL data is exported every 15 seconds.
  5. Overview of Schema Contracts

    Schema Contracts allow you to create filtered versions of a source graph (either a federated graph or a monograph) to provide tailored APIs for specific consumers. This is useful for improving security, ensuring data privacy, and reducing API bloat by hiding irrelevant fields from specific user groups.

    Key terminology:

    • Source Graph: The original federated graph or monograph that is being filtered.
    • Contract Graph / Contract: The resulting filtered version of the source graph.
  6. Overview of WunderGraph Cosmo

    WunderGraph Cosmo is a Full Lifecycle GraphQL API Management Solution designed to manage Federated Graphs at scale. It provides integrated support for composition checks, routing, analytics, and distributed tracing. Cosmo supports monolithic GraphQL APIs as well as Federation v1 and v2 (including Subscriptions) and can be deployed locally, on-premises, or as a managed cloud service.
  7. Overview of Response Caching in Cosmo Router

    The Response Cache (Experimental/Alpha) prevents subsequent requests from reaching upstream subgraphs by caching two types of responses:

    1. Entity fetches: Requests sent via the _entities root field. Entries are keyed per entity and per selection set.
    2. Root query fetches: Requests for root fields selected by the client. The entire answer is stored as one entry, keyed by operation text and variable values.

    Important Constraints:

    • Only queries are cached; mutations and subscriptions are never cached.
    • Responses containing GraphQL errors are never cached.
    • This feature is in alpha and not recommended for production environments.
  8. Overview of Cosmo Router Plugins

    Router plugins are extensions that run as separate processes locally alongside the Cosmo Router, communicating via the gRPC protocol. They allow developers to implement GraphQL resolvers that access any data source (legacy systems, REST APIs, SOAP, etc.) without deploying standalone 'Subgraph' services.

    Key architectural features include:

    • Fault Isolation: Because plugins run in separate processes, a plugin crash will not bring down the Router.
    • Lifecycle Management: The Cosmo Router manages plugin lifecycles, including hot-reloading without service interruption.
    • Framework: Built on the HashiCorp go-plugin framework for enterprise-grade reliability and process isolation.
    • Compatibility: 100% compatible with existing Apollo Federation Subgraph implementations.
  9. Overview of GraphQL File Uploads in Cosmo

    Cosmo supports uploading files through the router using the multipart/form-data content type, following the GraphQL multipart request specification. It supports both single and multiple file uploads; however, batch uploads are not supported.
  10. Overview of Cosmo Router Cost Control

    Cost Control prevents resource exhaustion by estimating GraphQL query complexity before execution. It assigns weights to fields and types to calculate a total cost. If the router is in enforce mode and a query exceeds the configured max_estimated_limit, the request is rejected before any subgraph requests are made. The implementation is based on the IBM GraphQL Cost Directive Specification but adapted for Federation, meaning it accounts for the query plan (entity calls, @requires fetches) and multiplies both type weights and children's costs by list sizes.
  11. Overview of Subgraph Check Extensions

    Subgraph Check Extensions allow you to validate proposed schema changes using your own custom validator before they are deployed to production. This is useful for enforcing company-specific naming conventions, adhering to internal standards, or triggering external notifications (e.g., alerting frontend teams about expected breaking changes) via a custom endpoint.
  12. Overview of Router-level Feature Flags

    Router-level feature flags allow you to swap a subgraph at request time without a redeploy. Each flag defines a replacement subgraph; when a request includes a matching header or cookie, the router resolves the target subgraph to the flagged replacement instead of the default one.