HUB
Sign inSign up

jgopsill/swapiql

By jgopsill

•Updated almost 6 years ago

A GraphQL wrapper for the Star Wars REST API

Image
0

10K+

jgopsill/swapiql repository overview

⁠SWAPIQL

A GraphQL wrapper for the SWAPI REST API⁠.

GitHub GitHub go.mod Go version

Docker Cloud Automated build Docker Cloud Build Status Docker Image Size (tag) Docker Pulls

⁠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.

localhost:3000/playground localhost:3000/voyager

⁠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
  1. To run the the docker image
docker run -p 3000:3000 jgopsill/swapiql
  1. To run the code, pull repo and run
go run main.go
  1. Running the code in debug mode
GQL_DEUBUG=true go run main.go
  1. 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

Tag summary

Content type

Image

Digest

Size

16.7 MB

Last updated

almost 6 years ago

docker pull jgopsill/swapiql
⌂ 换网址