Before contributing to the WunderGraph Cosmo repository, please open an issue to discuss the changes you would like to make. Alternatively, you can also open a discussion in the WunderGraph Discussions. We are open to all kinds of contributions, including bug fixes, new features, and documentation improvements.
The following sections provide a guide on how to contribute to the WunderGraph Cosmo repository.
This guide assumes you have already installed the following software:
- make (should be installed on all linux / IOS systems)
- golang
>= 1.18
- pnpm >= 8.7.0
- Node.js LTS. You can also pnpm to install Node.js.
- docker desktop (includes: engine, buildkit & compose) or:
- docker engine with:
- docker buildkit, with optionally: docker buildx plugin
- docker compose plugin
NPM packages are managed as a pnpm workspace. This means during development all dependencies are linked.
The root package.json
provides all scripts you need to orchestrate the development workflow.
Most of the project have a .env.example
file. Replace .env.example
with .env
and fill in the required values.
You can bootstrap the repository with the following command:
make
Ready! You can now start contributing to the WunderGraph Cosmo repository. Feel free to open an issue or pull request to add a new feature or fix a bug.
We use conventionalcommits for changelog generation and more structured commit messages.
In order to enforce this standard we use a linter on pre-commit hook. This functionality is provided by husky.
In some setup, you have to tell husky where to find your package manager or binaries. Here is the file .huskyrc
you have to put in your user home directory.
export NVM_DIR=/home/starptech/.nvm
[ -s /home/starptech/.nvm/nvm.sh ] && \. /home/starptech/.nvm/nvm.sh # This loads nvm
# golang
export PATH=$PATH:/usr/local/go/bin
export PATH="$PATH:$(go env GOPATH)/bin"
This plugins simplifies the commit message creation process.
We merge all pull requests in squash merge
mode. You're not enforced to use conventional commit standard across all your commits, but it's a good practice and increase transparency. At the end it's important that the squashed commit message follow the standard.
- Docker
- Docker Compose V2
- NodeJS LTS
- PNPM 8+
- Go 1.21+
- wgc
- .env/.env.local (see below)
All services work with environment variables. You can find the default values in the .env.example
file.
Please copy the variables to .env
(the same for studio but with .env.local
) and adjust the values to your needs.
Bootstrapping Cosmo for local development is easy. Just run the following commands in order:
# 1️⃣ Setup the repository, build libraries and start all services (Wait a few seconds until Keycloak is ready)
make
# 2️⃣ Run migrations and seed the database
make migrate && make seed
# 3️⃣ Start the control plane
make start-cp
# 4️⃣ Create the demo and copy the JWT printed at the bottom
make create-demo
# 5️⃣ Start the subgraphs
OTEL_AUTH_TOKEN=<jwt-token> make dc-subgraphs-demo
# 6️⃣ Put the JWT from the previous step into the router/.env as GRAPH_API_TOKEN and start the router
make start-router
# ✨ Finally, Start the studio (http://localhost:3000) and explore the Cosmo platform
make start-studio
Navigate to http://localhost:3000/ and login with the default credentials:
Username: [email protected]
Password: wunder@123
Navigate to the cli directory and replace .env.example
with .env
. After that you can run commands against your local Cosmo instance.
cd cli && pnpm wgc -h
Clean up all containers and volumes by running make infra-down-v
. You can repeat the steps above to bootstrap the platform again.
We manage multiple compose files:
docker-compose.yml
: The default compose file. It contains all services that are required to run the platform for development.docker-compose.full.yml
: This compose file contains the full Cosmo platform. It is used for demo and testing.docker-compose.cosmo.yml
: This compose file allows to build all Cosmo components and manage them in a single compose file. It is used for testing and releasing.
Clean up a compose stack before starting another one!