This simple Star Wars API GraphQL wrapper with cache.
This application was created as a "home recruitment task" to the Polish company based in Cracow - Dev and Deliver.
- Feedback from the company:
We continue the process with other candidates!
- My feedback after recruitment process:
Do not waste your time to the recruitment process, after final task submit I wait two weeks to any response (they clone the repo in the same day I submitted the link), finally I got plain, soulless email with list of things I did wrong, any call from recruiter side. In summary: process experience = F
- 🎁 Repository: standard Git repository
- 🌈 Framework: nest.js
- 🛠️ Tools: prisma orm, graphql
- 💎 Others: docker and docker-compose, cqrs, postgresql
This application uses GraphQL. You can find the GraphQL playground at http://localhost:3000/graphql
.
Currently, the following queries are available:
film(id: number)
- returns a film by idallFilms(page?: number)
- returns all films, with optional paginationplanet(id: number)
- returns a planet by idallPlanets(page?: number)
- returns all planets, with optional paginationspecies(id: number)
- returns a species by idallSpecies(page?: number)
- returns all species, with optional paginationstarship(id: number)
- returns a starship by idallStarship(page?: number)
- returns all starship, with optional paginationvehicle(id: number)
- returns a vehicle by idallVehicles(page?: number)
- returns all vehicles, with optional pagination
uniqueWords
- returns table of pairs (word-frequency) separated by\n\r
characters, pairs based on the opening crawl of all films,mostOftenName
- returns the most common name in the opening crawl of all films.
query {
film(id: 1) {
title
// rest fields
}
}
To run tests type and run: npm run test
in the root directory. The app contains external API tests, 22 tests in total.
Result:
Test Suites: 6 passed, 6 total
Tests: 22 passed, 22 total
Snapshots: 0 total
Time: 39.145 s, estimated 44 s
- Install Docker.
- Install Node.js.
- Clone the repository.
- Get and run database:
docker run --name swapi-gql-db -p 5432:5432 -d -e -e POSTGRES_PASSWORD="passw123" postgres:13.1-alpine
- Type and run:
npm install
in the root directory. - Generate the database schema:
npx prisma db push
- Type and run:
npm run start
in the root directory. - Open
http://localhost:3000/graphql
in your browser to see the GraphQL playground.
- Install Docker.
- Clone the repository.
- Type and run:
docker-compose build -d
in the root directory. - Type and run:
docker-compose up -d
in the root directory. - Open
http://localhost:3000/graphql
in your browser to see the GraphQL playground.