graphql-engine/cli/CONTRIBUTING.md
Marion Schleifer 5fa2e489e8 improve cli contributing.md
## Description

As discussed with @scriptonist, I went through the instructions on the `CONTRIBUTING.md` file of the CLI. The instructions largely work, but there is one section we need to add. I made a comment.

## Changelog

-  `CHANGELOG.md`:  No changelog is required.

## Affected components

-  CLI

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3185
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 00776de89ef745d24acd74beaebcdc2c11889597
2021-12-29 02:19:27 +00:00

3.2 KiB

Contributing

Thank you for your interest in the Hasura GraphQL Engine CLI.

The CLI is written in Go using the popular package spf13/cobra.

Find an issue to work on

All CLI related issues are labelled as c/cli. If you're new to the CLI codebase, you can check out the good-first-issue label for issues that should be fairly easy to implement.

If you are a first-time contributor, feel free to post your doubts/questions in #contrib channel on hasura discord server.

Pre-requisites

The following dependencies need to be installed in order to work on the CLI codebase:

Set up the repository

You can follow your existing Golang workflow to fork, work on a branch and submit PR. If you're new to forking and using branches, please execute the following commands and make sure the import paths are correct:

  • Fork the repo on GitHub
  • git clone https://github.com/<your-username>/graphql-engine
  • cd graphql-engine/cli
  • git remote add upstream https://github.com/hasura/graphql-engine
  • git checkout -b <branch-name>

Install dependencies

Install the dependencies as follows:

make deps

Development

Once everything is installed and running, you can start working on the feature/fix that you picked up.

Run the server

Docker Compose is the easiest way to run graphql-engine.

  1. From the graphql-engine directory, run cd install-manifests/docker-compose.
  2. From inside that directory, run docker-compose up -d.

The GraphQL endpoint will be at https://localhost:8080/v1/graphql.

The console will be available at https://localhost:8080/console.

Assets

If you modify files in assets/, run make assets.

Submit a PR

Commit, push and submit the PR.

Tests

When you're adding a new feature, it is encouraged to add integration tests and unit tests wherever possible.

Please run all the tests and make sure everything passes before submitting the PR.

  1. Set HASURA_TEST_CLI_HGE_DOCKER_IMAGE to the docker image of the server that you want the tests to run against. For example: export HASURA_TEST_CLI_HGE_DOCKER_IMAGE="hasura/graphql-engine:v2.1.0".

  2. e2e tests look for a hasura binary in PATH, you can either make sure it's available as hasura in your PATH or set HASURA_TEST_CLI_PATH to the binary path that you want to run the tests with. You'll get the path from running the build (see "Builds" below).

  3. Run the full suite by executing make test-all.

Builds

To build a binary, execute the following command:

make build

If you get an error running the above, run this command:

make build-cli-ext copy-cli-ext

This will output cross-platform binaries to the _output directory.