https://github.com/thebeachmaster/go-graphql-gateway
A dead-simple GraphQL gateway for all your federated Golang GraphQL server needs
https://github.com/thebeachmaster/go-graphql-gateway
federation fiber fiber-framework gateway gateway-api go golang graphql nautilus
Last synced: 3 months ago
JSON representation
A dead-simple GraphQL gateway for all your federated Golang GraphQL server needs
- Host: GitHub
- URL: https://github.com/thebeachmaster/go-graphql-gateway
- Owner: TheBeachMaster
- License: mit
- Created: 2023-03-12T16:31:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T19:12:40.000Z (over 2 years ago)
- Last Synced: 2025-06-28T17:54:50.947Z (3 months ago)
- Topics: federation, fiber, fiber-framework, gateway, gateway-api, go, golang, graphql, nautilus
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go GraphQL Gateway
- A dead-simple GraphQL gateway for all your federated Go GraphQL server needs.
Uses [Nautilus](https://github.com/nautilus/gateway) and [Fiber](https://github.com/gofiber/fiber)
## TLDR;
If you're just looking for a quick and dirty implementation of a federated gateway, paste this code into your `main.go` file, package and ship.
```go
package mainimport (
"fmt"
"net/http""github.com/nautilus/gateway"
"github.com/nautilus/graphql"
)func main() {
// change this to point to your GraphQL servers
schemas, err := graphql.IntrospectRemoteSchemas(
"http://localhost:4000/graphql",
"http://localhost:4001/graphql",
"http://as.many.urls.as.you.want:6969/graphql"
)
if err != nil {
panic(err)
}// create the gateway instance
gw, err := gateway.New(schemas)
if err != nil {
panic(err)
}// your GraphQL endpoint is http(s)://host(:port)/graphql <- executes queries on POST
// navigating to this url on the browser will show the GraphQL playground UI
http.HandleFunc("/graphql", gw.PlaygroundHandler)// start the server
fmt.Println("Starting server")
err = http.ListenAndServe(":8082", nil)
if err != nil {
fmt.Println(err.Error())
}
}
```## Usage
- Create a new `.env` file based on `.env.example` file
- `GRAPHQL_ENDPOINTS` variable should be in the format `"http://yourendpoint1","http://youendpoint2",...`
- `USE_FILE_CONFIG` variable should be set to `true` if you want to set/use your configs inside `config/config.yaml` file (useful for K8s-like deployments).- Your app will be running on port `8082` and your endpoint will be `api/graphql` and `api/playground` for the playground
- Build the binary `make build` or `make build-mac` for Mac OS
> Alternatively you can build a Docker image with the Dockerfile provided
- Health check endpoint `/ruok`