swapiql

command module
v0.0.0-...-a271727 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2021 License: MIT Imports: 8 Imported by: 0

README

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.

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL