Mini GraphQL server for querying and mutating a small database of vehicles.
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 for making generation of mock data painless. 🦘
- 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
.
{
getAllCars {
id
make
model
year
vin
}
}
{
getCarById(id: "60e27002aed956ce6772d774") {
id
make
model
year
vin
}
}
{
getCarsByMakeAndModel(make: "Acura", model: "TL") {
id
make
model
year
vin
}
}
mutation {
createCar(
make: "Acura",
model: "TL",
year: 1998,
vin: "1D4PT5GK8BW557445"
) {
id
make
model
year
vin
}
}
mutation {
updateCar(
id: "60e27002aed956ce6772d774",
make: "Acura",
model: "TSX",
year: 1998,
vin: "1D4PT5GK8BW557445"
) {
id
make
model
year
vin
}
}
mutation {
deleteCar(id: "60e27002aed956ce6772d774") {
id
make
model
year
vin
}
}
yarn start
yarn lint
yarn lint:fix
yarn test
yarn test:coverage
yarn build
yarn clean
The runtime environment for this application requires
node >= 14.15.0
andyarn >= 1.22.4
.
This application makes use of
ESLint
andEditorConfig
. Each of these features requires an extension be installed in order to work properly with IDEs and text editors such as VSCode.