- In order to populate and run the mongo database, you need
Docker
anddocker-compose
. Run
docker-compose up
- To make the API work, first install all dependencies (note that
npm@7
was used to generate thepackage-lock
)
npm ci
- And finally you can run the express server
npm start
- Go to
http://localhost:3000/graphql
The API consists of express
server, mongo
database and graphql
. In order to simplify the task a bit and to write everything from scratch, the libraries mongoose
, graphql-compose
, and graphql-compose-mongoose
are used.
The mongo
database is populated with the provided json file with no additional changes. That implies that a new favorite
field is not set and when queried using grapghl the value can be true
, false
, and also null
.
The source code is written in TypeScript. To simplify the development and avoid any explicit transpilation step, ts-node
is used to run the project instead of node
. Supposedly, ts-node
is acceptable to run in production when there is the --transpile-only
flag specified.
Mongo DB currently contains a single collection with no additional indices. It makes sense to add indices to all the fields that are used to filter results.
The mongoose
schema is generated by an on-line tool. It would require just slightly more effort to have a detailed schema with all nested fields. As of now, all the more complex nested fields (e.g. specific objects) are "just" JSON
objects.
As this was a small task there wasn't much to cover by tests. There is a single utility function - covered (npm test
). Other than that, we could test if DB queries query what are supposed to query, or possibly cover the task specification, i.e. that the API handles whatever is specified in the requirements.
For easier maintenance of the project, we could setup eslint rules or TypeScript type check in a pre-commit or pre-push hook. Or anywhere on the way before the code gets to the master/main branch. Currently, there is only prettier
config for consistent code formatting.
This repository contains a coding exercise for new developers joining the backend development team.
Fork this repository and create your own exercise!
We have provided you with Pokemon data in a json file. Your mission is to create a database and expose the database to an API. Basically, you need to:
- Design the database to store information for the Pokemon data
- Load the database with the data
- Implement the API Interface with the following features:
- Query pokemons with the options:
- Pagination
- Search by name
- Filter by pokemon type
- Filter by favorite
- Query a pokemon by id
- Query a pokemon by name
- Query list of pokemon types
- Mutation to mark/unmark pokemon as favorite
- Query pokemons with the options:
- Test are important and if time allows it, we'd like to see some test coverage
Remember that our technology stack is:
- Node.js (Typescript, Fastify)
- GraphQL (Nexus)
- PostgreSQL (Objection.js)
You can use the framework that you prefer, but please write the challenge in JS or TS. You can choose PostgreSQL / MongoDB like database, be free but take in consideration the best database to store the data.