Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions docs/VM-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# VM setup

How to run the GraphQL API (`server/`) on the group VM and check that it works.

## Run the API

`DATABASE_URL` must point at the `crate` database, for example in `server/.env`:

```
DATABASE_URL=postgres://t19:<password>@127.0.0.1:5432/crate
```

```bash
pnpm install
pnpm --filter @t19/server db:migrate # create the catalog tables
pnpm --filter @t19/server db:seed # replace the catalog with the sample albums
pnpm --filter @t19/server build
pnpm --filter @t19/server start # http://localhost:3001/graphql
```

## Smoke suite

Run on the VM after a deploy. Each command prints what to expect. The
expectations assume the sample data from `db:seed`.

```bash
API=http://localhost:3001/graphql
gql() { curl -s "$API" -H 'content-type: application/json' -d "$1"; echo; }
```

1. The API answers. Expect `{"data":{"__typename":"Query"}}`.

```bash
gql '{"query":"{ __typename }"}'
```

2. Search is case-insensitive. Expect `totalCount` 4 for both.

```bash
gql '{"query":"{ a: searchAlbums(input:{query:\"blue\",sort:RELEVANCE},first:5){ totalCount } b: searchAlbums(input:{query:\"BLUE\",sort:RELEVANCE},first:5){ totalCount } }"}'
```

3. A single word also matches artist names, and artists and genres resolve.
Expect A Love Supreme and Blue Train, both by John Coltrane.

```bash
gql '{"query":"{ searchAlbums(input:{query:\"coltrane\",sort:TITLE_ASC},first:5){ totalCount edges { node { title releaseYear artists { name } genres { name } } } } }"}'
```

4. Facets ignore their own filter. With Rock (id 4) selected, expect
`totalCount` 7, `genreFacets` still listing all seven genres, and
`decadeFacets` counting only Rock albums.

```bash
gql '{"query":"{ searchAlbums(input:{query:\"\",genreIds:[\"4\"],sort:TITLE_ASC},first:5){ totalCount genreFacets { genre { name } count } decadeFacets { decade count } } }"}'
```

5. Paging. Expect `hasNextPage` true and an `endCursor`. Paste the cursor in as
`after` to get the next two albums, with no album repeated.

```bash
gql '{"query":"{ searchAlbums(input:{query:\"\",sort:RELEASE_YEAR_DESC},first:2){ edges { node { title releaseYear } } pageInfo { hasNextPage endCursor } } }"}'
gql '{"query":"{ searchAlbums(input:{query:\"\",sort:RELEASE_YEAR_DESC},first:2,after:\"<endCursor>\"){ edges { node { title releaseYear } } pageInfo { hasNextPage endCursor } } }"}'
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"dev": "pnpm --filter @t19/client dev",
"build": "pnpm --filter @t19/client build",
"build": "pnpm -r build",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
Expand Down
Loading