https://github.com/dzervoudakes/graphql-server
Mini GraphQL server for querying and mutating a small database of vehicles.
https://github.com/dzervoudakes/graphql-server
docker-compose express graphql graphql-server mongodb mongoose typescript
Last synced: 3 months ago
JSON representation
Mini GraphQL server for querying and mutating a small database of vehicles.
- Host: GitHub
- URL: https://github.com/dzervoudakes/graphql-server
- Owner: dzervoudakes
- License: mit
- Created: 2021-07-04T02:02:36.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-09T00:49:12.000Z (over 4 years ago)
- Last Synced: 2025-02-03T11:51:00.084Z (over 1 year ago)
- Topics: docker-compose, express, graphql, graphql-server, mongodb, mongoose, typescript
- Language: TypeScript
- Homepage:
- Size: 740 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphQL Server
> Mini GraphQL server for querying and mutating a small database of vehicles.
[](https://prettier.io/)
## Motivation
Historically I'm more familiar with consuming GraphQL APIs on the frontend (Apollo Client is awesome, by the way). Until recently, I hadn't yet created my own GraphQL server from scratch and so I thought it would be a fun learning experience. I've worked with Graphene in a Python/Flask app before, though I was curious to explore creating a Node/Express solution as well.
Shout out to [mockaroo](https://mockaroo.com/) for making generation of mock data painless. 🦘
## Project Setup
- Ensure that `Docker` is installed and running
- In a terminal window at the project root, run `yarn install`
- Run `docker compose up` to seed the database and start the Express server
While the server is running, the GraphiQL playground can be accessed in a web browser at `http://localhost:3000/graphql`.
## Example Queries
### Get All Cars
```gql
{
getAllCars {
id
make
model
year
vin
}
}
```
### Get Car by ID
```gql
{
getCarById(id: "60e27002aed956ce6772d774") {
id
make
model
year
vin
}
}
```
### Get Cars by Make and Model
```gql
{
getCarsByMakeAndModel(make: "Acura", model: "TL") {
id
make
model
year
vin
}
}
```
## Example Mutations
### Create Car
```gql
mutation {
createCar(
make: "Acura",
model: "TL",
year: 1998,
vin: "1D4PT5GK8BW557445"
) {
id
make
model
year
vin
}
}
```
### Update Car
```gql
mutation {
updateCar(
id: "60e27002aed956ce6772d774",
make: "Acura",
model: "TSX",
year: 1998,
vin: "1D4PT5GK8BW557445"
) {
id
make
model
year
vin
}
}
```
### Delete Car
```gql
mutation {
deleteCar(id: "60e27002aed956ce6772d774") {
id
make
model
year
vin
}
}
```
## Build Scripts
### Start Server on Port 3000
```sh
yarn start
```
### Run Linting
```sh
yarn lint
```
### Run Linting with Fix
```sh
yarn lint:fix
```
### Run Unit Tests
```sh
yarn test
```
### Run Unit Tests with Coverage Report
```sh
yarn test:coverage
```
### Build for Production
```sh
yarn build
```
### Remove Output Directories
```sh
yarn clean
```
## Technical Requirements
> The runtime environment for this application requires `node >= 14.15.0` and `yarn >= 1.22.4`.
## Configuration
> This application makes use of `ESLint` and `EditorConfig`. Each of these features requires
> an extension be installed in order to work properly with IDEs and text editors such as VSCode.