router

module
v0.0.0-...-4a72ded Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2024 License: Apache-2.0

README

Cosmo Router

The router is the component that understands the GraphQL Federation protocol. It is responsible for routing requests to the correct service and for aggregating the responses. It is in connection with the control plane to register itself and to send metrics.

Getting Started

Prerequisites

Use the .env.example file to create a .env file with the specified environment variables.

make dev

Code Generation

Code is committed to the repository, but if you want to regenerate the code, you can run the command in the root of the repository:

make generate-go

Develop with a local Engine version

You can uncomment te replace directive in the go.mod file to use the local version of the graphql-go-tools package. You only need to ensure that you have checked out the graphql-go-tools repository in the same parent directory as the router repository.

replace github.com/wundergraph/graphql-go-tools/v2 => ../../graphql-go-tools/v2

Build your own Router

See Router Customizability how to build your own router.

Architecture

The router is a HTTP server that accepts GraphQL requests and forwards them to the correct service. The core aka the Engine implements the GraphQL Federation protocol and is responsible for parsing the request, resolving the query and aggregating the responses. We use Connect to communicate with the controlplane. Connect is framework build on top of gRPC and simplify code-generation and reuse between Studio -> Controlplane <- Router.

Directories

Path Synopsis
cmd
gen
internal
docker
Package docker implements helper functions we use while running under Docker.
Package docker implements helper functions we use while running under Docker.
jwt
pkg
art
authentication
Package authentication implements the types and functions used to load and validate user authentication
Package authentication implements the types and functions used to load and validate user authentication
config
Package loadvariable implements helper functions for retrieving values from wgpb.ConfigurationVariable instances.
Package loadvariable implements helper functions for retrieving values from wgpb.ConfigurationVariable instances.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL