The shopper server is graphql api running node that is built with fastify and mercurius. It is accompanied by a postgres database running in a docker container.
Ensure that you are in the server directory before continuing through the setup docs. cd server/
This server runs node v18.20.4
, which can be installed with nvm use 18.20.4
.
cp .env.example .env
to initialize your environment- Open
.env
and edit the postgres password (POSTGRES_PASSWORD). For local development, it can be set to any value
- Start the database:
docker-compose up
- Stop the database:
docker-compose down
- Install dependencies:
npm ci
- Run the server:
npm run dev
- NOTE:
npm start
can be used to run the app in production mode
- Run the tests:
npm test
The server has graphiql enabled. Visit http://localhost:3000/graphiql to visit an in-browser tool for writing, validating, and testing graphql queries. The server graphql documentation is also visible from this page.
mutation {
addItem(
item: {
name: "test item"
description: "test description"
quantity: 1
completed: false
}
) {
item {
id
name
description
quantity
completed
}
}
}
mutation {
updateItem(
item: {
id: 1
completed: true
name: "thomas update"
description: "updated description"
quantity: 2
}
) {
item {
id
name
description
quantity
completed
}
}
}
mutation {
deleteItem(item: { id: 1 }) {
item {
id
name
completed
}
}
}
query {
getItems {
id
name
description
quantity
completed
}
}