SWAPIQL
A GraphQL wrapper for the SWAPI REST API.
Introduction
This repo is a proxy GraphQL wrapper service for the SWAPI REST API enabling the community to access their Star War trivia in GraphQL format. It is written in Go and has an associated Docker image for people to pull and run on their own platforms.
Now there is no need to access multiple endpoints and synthesise your Star Wars data. SWAPIQL has you covered. Just ask it what data you want and off it will go to get it for you.
The container exposes port 3000
and the GraphQL endpoint is at the root (i.e. localhost:3000/graphql
). The server also provides GraphQL Playground and Voyager at localhost:3000/playground
and localhost:3000/voyager
, respectively. These are pre-configured to work with the container's GraphQL endpoint.
Serving at a different endpoint
If you want to use a different endpoint other than the root endpoint then you can create a environment variable called GQL_PREFIX
and add the prefix that appends to the root. E.g. localhost:3000/swapiql/[graphql|playground|voyager]
will use GQL_PREFIX=/swapiql
.
Logging
Zerolog is used for logging in the code and defaults to logging info information. This can be changed to log debug information using the GQL_DEBUG=true
environment variable.
Response cache
Go-cache is used to provide url response caching to reduce the number of repeated calls to the REST API.
Useful commands
- To run the the docker image
docker run -p 3000:3000 jgopsill/swapiql
- To run the code, pull repo and run
go run main.go
- Running the code in debug mode
GQL_DEUBUG=true go run main.go
- Building the docker image
DOCKER_BUILDKIT=1 docker build --tag swapiql .
N.b. DOCKER_BUILDKIT
env var removes the intermediate images after build.
TODO
Finish wrapper first parse
Document the schema
Add search
Caching
- Testing and errors
Useful links