https://github.com/kamilkodzi/star-api
Graph QL wrapper for https://swapi.dev/ ( The best Star Wars API )
https://github.com/kamilkodzi/star-api
apollo-server apollographql dataloader deduplication docker docker-compose graphql hot-reload nodemon
Last synced: 6 months ago
JSON representation
Graph QL wrapper for https://swapi.dev/ ( The best Star Wars API )
- Host: GitHub
- URL: https://github.com/kamilkodzi/star-api
- Owner: kamilkodzi
- Created: 2023-12-07T15:08:43.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-10T20:03:49.000Z (over 2 years ago)
- Last Synced: 2024-04-25T05:05:18.433Z (about 2 years ago)
- Topics: apollo-server, apollographql, dataloader, deduplication, docker, docker-compose, graphql, hot-reload, nodemon
- Language: TypeScript
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# If you ever wonder how to start working with Apollo server + GraphQL
This is just starting point for further developlemt.
### Area to investigate:
1. Add Redis server to docker-compose+network and use in project
2. Cache each fetch results in to redis (watchout for null responses)
3. Is possible to use just `Film` query with optional param`(id)` and return `Film[] | Film` instead of using `Films`
4. Add tests - probably Jest can suit all needs
## This is simple example of reducing deduplication (n+1) problem
Packaget that fix problem:
`datasource-rest`
`dataloader`
## Running application locally:
My node version = 20.9.0
1. `git clone https://github.com/kamilkodzi/star-api.git`
1. `cd star-api`
1. `npm i`
1. `npm run dev`
## Running applicaton with Docker
Be sure you have docker instaled on your system, then:
1. `cd infra\docer-compose\`
1. `docker-compose up`
1. visit `http://localhost:4000/`
Projest starts on dev mode with hot-reloading,
so uou can add any console.log() just like that
[TIP]:
Use query bellow and watch console.
Each fetch will be prompt
### Fishy query with deduplication:
```js
query Films {
films {
title
producer
planets {
terrain
name
films {
species {
name
language
}
}
}
characters {
name
}
vehicles {
name
pilots {
name
}
}
}
}
`
```