Cosmo Connect Tutorials for Router Plugins and gRPC Services
Cosmo Connect lets you build federated GraphQL APIs without requiring backend teams to run GraphQL servers or frameworks. You define a schema, compile it to gRPC, and let the Cosmo Router handle query planning and batching.
You can get started in three ways:
- Router Plugins run directly inside the Router, cutting out extra deployments and reducing complexity
- gRPC Services are standalone processes, ideal for teams that need clear ownership, scaling, and deployment boundaries
- The Advanced Demo ties everything together, combining plugins, GraphQL servers, and external services in one federated graph
View the full tutorial
This tutorial introduces gRPC Router Plugins—lightweight subgraphs compiled to binaries and managed directly by the Cosmo Router. Instead of deploying a separate GraphQL service, you’ll define a schema, generate gRPC code, and run your business logic as a router-managed process. This keeps latency low, simplifies deployments, and makes it easy to integrate any API.
In this example, you’ll create a plugin called starwars
that wraps a minimal portion of the public SWAPI API. It’s a stand-in for your own REST APIs, databases, or third-party services.
The setup includes:
- Cosmo CLI for scaffolding and managing plugins
- Cosmo Router to run the plugin and compose it into your federated graph
- gRPC tooling for automatic code generation and type-safe development
The steps include:
- Initializing a plugin project with the Cosmo CLI
- Defining a GraphQL schema (
schema.graphql
) - Generating protobuf code with
wgc router plugin generate
- Implementing resolvers in Go using the built-in HTTP client
- Publishing the plugin with
wgc router plugin publish
By the end of this tutorial, you’ll be able to query the people field in your federated graph using a router-managed plugin with no separate service deployment.
View the full tutorial
This tutorial shows how to build a standalone gRPC service and connect it to your federated graph without running a GraphQL server. Unlike Router Plugins, gRPC services run as independent processes, making them ideal for teams that want clear ownership boundaries, separate scaling, and flexible deployment patterns.
You’ll scaffold a service in either TypeScript or Go using the Cosmo CLI templates. The tutorial walks you through designing a project management schema, generating protobuf files, and implementing queries and mutations.
The setup includes:
- Cosmo CLI to scaffold and configure the service
- Connect RPC for modern, type-safe gRPC development
- Cosmo Router to federate your service into the supergraph
The steps include:
- Initializing a service project with
wgc grpc-service init
- Defining a GraphQL schema with queries and mutations
- Generating protobuf and Connect RPC code
- Implementing business logic in Go or TypeScript
- Running the service alongside the Cosmo Router
- Testing your integration in GraphQL Playground at
http://localhost:3002
By the end of the tutorial, you’ll have a running gRPC service that federates cleanly into the Cosmo Router. This approach gives teams full lifecycle control and is ideal when you need separate scaling and ownership boundaries.
View the full demo on GitHub
This tutorial demonstrates a federated GraphQL architecture that combines a Cosmo Connect Router Plugin with a standalone Apollo subgraph, showing how plugins can bridge to external services without rewriting backends.
The setup includes:
- Users Subgraph: A Go-based Router Plugin (Cosmo Connect) managed by the Router—no separate service needed
- Products Subgraph: A standalone GraphQL server using Apollo Server (running on port 3011)
- Cosmo Router: Composes both subgraphs into a unified GraphQL API (running on port 3010)
The steps include:
- Cloning the demo repository and installing dependencies
- Building the plugin, starting the Router, and running the subgraphs with
npm start
- Opening the GraphQL Playground at
http://localhost:3010
- Running queries that combine users and products, demonstrating plugin-powered integration with external APIs
Key takeaways:
- Schema-first GraphQL development with automatic protobuf and gRPC code generation
- Schema-driven code generation with strong typing from GraphQL schema to gRPC definitions
- Integration with external APIs through the plugin layer
- Embedded subgraphs for high performance by running inside the router
- Combination of plugin-based and standalone GraphQL services for compatibility
All three tutorials demonstrate how to integrate services into a federated graph without building GraphQL servers. Router Plugins simplify deployment by being managed directly by the Router, gRPC Services provide independence and flexibility, and the Advanced Demo shows how mixed architectures can live side by side. You can start with a plugin or service, then explore the hybrid demo to see how these approaches fit together at scale.
Frequently Asked Questions (FAQ)
Router Plugins are easiest to start with if you want to avoid extra deployments—they run as processes managed by the Router. Choose the gRPC Service tutorial if you need independent scaling and ownership. The Cosmo Plugin Demo shows how to mix both approaches with existing subgraphs.
No. Both tutorials use a schema contract but avoid GraphQL server runtimes. The Cosmo Router handles GraphQL parsing, validation, and batching.
Yes. The Cosmo Plugin Demo demonstrates a federated graph that mixes Router Plugins, standalone GraphQL servers, and external services.
The tutorials include Go and TypeScript templates. gRPC itself is language-agnostic and widely supported, including Java, Python, Rust, and C#.
Router Plugins run as processes managed by the Router for simpler deployments and lower latency. Services are independent and ideal when you need separate scaling and ownership boundaries.