# graphql-audience

## Prerequisites

1. Make sure you have [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) and [pnpm](https://pnpm.io/installation) installed.
2. We are using private npm packages from our [monorepo](https://github.com/theorchard/orchard-suite) and npm.pkg.github.com registry.
   That means you need a valid access token for each of them.
   Follow this guide on how to setup NPM access.
   https://www.notion.so/Javascript-Package-Management-Setup-9553d5d491c94835aa787fdf0fc4838d
3. Familiarize yourself with [GraphQL at The Orchard](https://github.com/theorchard/docs/tree/master/graphql) before contributing!

## Setup

```bash
# use supported node version
nvm use

# install dependencies
pnpm

# create environment configuration
cp .env.shadow .env

# start your server
pnpm start
```

## Available Scripts

In the project directory, you can run:

### `pnpm start`

Runs the app in the development mode.
Open http://localhost:8080/graphql to view the playground in the browser.
The server will reload if you make edits.

**NOTE:**
**Running the project locally requires an active VPN connection.**

### `pnpm test:unit`

Runs unit tests in watch mode. In watch mode type `p` to enter a filter.

### `pnpm test:integration`

Runs integration tests against a local instance. **Note** that you need to run `pnpm start` in a different process first.

### `pnpm test`

Runs unit and integration tests. Run this before creating a PR.

### `pnpm lint`

Runs the js and graphql schema linter. Run this before creating a PR.

### `pnpm build`

Builds the app for production to the `build` folder.<br />

Note that this command is not required to run locally, it is run during the docker build steps.

### `pnpm generate:types`

Generates TypeScript types for resolvers.<br />

Run this every time you did a change to GraphQL schema

### `pnpm generate:openapi`

Generates TypeScript types for open api connectors.<br />

Run this every time the openapi connector schema changes

## Preparing code for PR

Check if your changes are working in the playground (`pnpm start`).
Do not forget to run `pnpm test:unit` and `pnpm typecheck` before creating a pull request.

### Commit name convention

`[type]: [short summary]`

where
`type` - commit type (add | update | remove | refactor | chore | fix | build | docs),
`short summary` - summary in present tense, not capitalized, no period at the end.

### PR name convention

`[Jira ticket]: [short summary]`
