After doing some cleanup on my projects list, I found a nearly-forgotten tool that I wrote a few months ago, and with some polishing and overhaul done, I'm happy to present to the world: aqueduct. To put it simply, it's a proxy service for GraphQL applications, utilizing a technology named schema-stitching at its core, to connect multiple GraphQL-powered data sources. Offering a ton of customization options, aqueduct can become to perfect companion if you need to bundle some services behind a single endpoint.
Let's see an example setup to gain some impressions! For our example configuration file named aqueduct.yaml
, we'll add the following:
endpoints:
- swapi:
endpoint: https://api.hygraph.com/simple/v1/swapi
- transit:
endpoint: https://bahnql.herokuapp.com/graphql
- pokemon:
endpoint: https://graphql-pokemon.now.sh/
enablePlayground: true
To deploy an aqueduct instance, you can simply use a compose file as shown below
version: '3.7'
services:
gateway:
image: brunoscheufler/aqueduct:latest
volumes:
- './aqueduct.yaml:/config/aqueduct.yaml:ro'
ports:
- '4000:4000'
environment:
NODE_ENV: production
If you launch your Docker Compose setup, you can access the aqueduct endpoint at http://localhost:4000
and execute some queries!
{
# Get some transit info from DB
search(searchTerm: "Berlin Hauptbahnhof") {
stations {
name
federalState
hasWiFi
}
}
# Load Swapi info
Person(name: "Luke Skywalker") {
birthYear
}
# And some Pokemon details
pokemon(name: "Pikachu") {
number
maxHP
}
}
I know the example query and setup above is a bit unrealistic, but you get the gist of it! To use aqueduct as a gateway with auth, you can add a JWT secret and it will automatically validate every request against that. By configuring aqueduct to pass headers you can authenticate with used services, and so on. The possibilities are pretty much endless!