Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# The following are aliases you can use with "cargo command_name"
[alias]
gateway = "run --package gateway"
router = "run --package router"
dev = "run --package qp-dev-cli"
subgraphs = "run --package subgraphs"
test_all = "test --workspace"
test_qp = "test --package query-planner -- --nocapture"
test_qpe = "test --package query-plan-executor -- --nocapture"
"clippy:fix" = "clippy --all --fix --allow-dirty --allow-staged"
"router-config" = "run --release -p gateway-config router-config.schema.json"
"router-config" = "run --release -p router-config router-config.schema.json"
14 changes: 7 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:
DOCKER_VENDOR: theguild
DOCKER_PLATFORMS: linux/amd64,linux/arm64
ZIG_VERSION: 0.14.1
BINARY_NAME: gateway
BINARY_NAME: hive_router

jobs:
config:
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
name: upload build artifact
with:
name: gateway_${{ matrix.name }}
name: hive_router_${{ matrix.name }}
path: target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
if-no-files-found: error
- name: Upload binaries to release
Expand All @@ -99,7 +99,7 @@ jobs:
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
asset_name: gateway_${{ matrix.name }}
asset_name: hive_router_${{ matrix.name }}
tag: ${{ github.ref }}
docker:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -129,14 +129,14 @@ jobs:
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
with:
path: artifacts
pattern: gateway_*
pattern: hive_router_*
- name: prepare artifacts
run: |
mkdir -p ./target/linux/arm64
mkdir -p ./target/linux/amd64

mv ./artifacts/gateway_linux_arm64/gateway ./target/linux/arm64/gateway
mv ./artifacts/gateway_linux_amd64/gateway ./target/linux/amd64/gateway
mv ./artifacts/${{ env.BINARY_NAME }}_linux_arm64/${{ env.BINARY_NAME }} ./target/linux/arm64/${{ env.BINARY_NAME }}
mv ./artifacts/${{ env.BINARY_NAME }}_linux_amd64/${{ env.BINARY_NAME }} ./target/linux/amd64/${{ env.BINARY_NAME }}
ls -ltra ./target/linux/arm64/
ls -ltra ./target/linux/amd64/
- uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
Expand All @@ -148,7 +148,7 @@ jobs:
id: docker
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
file: ./docker/gateway.Dockerfile
file: ./docker/router.Dockerfile
context: .
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ jobs:
- name: cargo clippy
run: cargo clippy --all

unit-benchmark:
benchmark:
strategy:
matrix:
include:
- name: "Query Planner"
- name: "query-planner"
package: "./lib/query-planner"
- name: "Executor"
- name: "executor"
package: "./lib/executor"
name: ${{ matrix.name }} Benchmark
name: benchmark / ${{ matrix.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
Expand All @@ -99,8 +99,8 @@ jobs:
name: ${{matrix.package}}-benchmark-results
path: ${{matrix.package}}/target/criterion

k6-benchmark:
name: Overall K6 Benchmark
router-benchmark:
name: benchmark / router
runs-on: ubuntu-latest
env:
NODE_NO_WARNINGS: true
Expand All @@ -120,10 +120,10 @@ jobs:
run: cargo build --release -p subgraphs
- name: Run subgraphs
run: ./target/release/subgraphs & sleep 5
- name: Build gateway
run: cargo build --release -p gateway
- name: Run gateway
run: ./target/release/gateway & sleep 5
- name: Build router
run: cargo build --release -p router
- name: Run router
run: ./target/release/hive_router & sleep 5
env:
HIVE_SUPERGRAPH_SOURCE: file
HIVE_SUPERGRAPH_PATH: bench/supergraph.graphql
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version-file: audits/.node-version
- run: cargo build --package gateway
- run: cargo build --package router
- run: npm install
working-directory: audits
- run: npm run test:federation-all
Expand Down
28 changes: 0 additions & 28 deletions .zed/debug.json

This file was deleted.

84 changes: 42 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[workspace]
members = [
"lib/query-planner",
"lib/gateway-config",
"lib/router-config",
"lib/wasm-lib",
"lib/executor",
"bin/dev-cli",
"bin/gateway",
"bin/router",
"bench/subgraphs",
]
resolver = "2"
default-members = ["bin/gateway"]
default-members = ["bin/router"]

[profile.dev]
debug = 2
Expand Down
22 changes: 2 additions & 20 deletions PROFILING.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
## Profiling using Samply


1. Configure `gateway/src/main.rs` to use `#[tokio::main(flavor = "current_thread")]` for better reading of the flamegraph.
2. Install `samply` by following: https://github.com/mstange/samply#installation
3. Build the gateway in profiling mode using: `cargo build --profile profiling -p gateway`
4. Run `samply` with your dev-cli args, for example:

```
samply record ./target/profiling/gateway SUPERGRAPH_PATH
```

## Profiling using Flamegraph

1. Install `flamegraph` by following: https://github.com/flamegraph-rs/flamegraph?tab=readme-ov-file#installation
2. Run `gateway` with the example command.
2. Run `router` with the example command.
3. Open the `flamegraph.svg` file

```
cargo flamegraph -p gateway --profile profiling -- SUPERGRAPH_PATH
cargo flamegraph -p router --profile profiling -- SUPERGRAPH_PATH
```

## Profiling with perfetto

1. Build GW in release mode: `cargo build --release -p gateway`
2. Run gateway in release mode with the following flag: `PERFETTO_OUT="1" RUST_LOG="trace" ./target/release/gateway bench/supergraph.graphql`
3. Use the generated `trace-*.json` file and load it into https://ui.perfetto.dev
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@

# Hive Router (Rust)

A fully open-source MIT-licensed GraphQL API gateway that can act as a [GraphQL federation](https://the-guild.dev/graphql/hive/federation) Gateway, built with Rust for maximum performance and robustness.
A fully open-source MIT-licensed GraphQL API router that can act as a [GraphQL federation](https://the-guild.dev/graphql/hive/federation) Router, built with Rust for maximum performance and robustness.

It can be run as a standalone binary or a Docker Image. Query planner can be used as a standalone Crate library.

[Binary Releases](https://github.com/graphql-hive/gateway-rs/releases) | [Docker Releases](https://github.com/graphql-hive/router/pkgs/container/router) | [Configuration reference](./docs/README.md)
[Binary Releases](https://github.com/graphql-hive/router/releases) | [Docker Releases](https://github.com/graphql-hive/router/pkgs/container/router) | [Configuration reference](./docs/README.md)

## Try it out

Start by creating a simple configuration file. You may use YAML or JSON formats.
Download Hive Router using the following install script:

```
curl -o- https://raw.githubusercontent.com/graphql-hive/router/main/install.sh | sh
```

> At the moment, only Linux runtimes are supported using a binary, see Docker option below if you are using a different OS.

Create a simple configuration file that points to your supergraph schema file:

```yaml
# hive-router.config.yaml
Expand All @@ -26,18 +34,18 @@ HIVE_SUPERGRAPH_SOURCE=file
HIVE_SUPERGRAPH_PATH=./supergraph.graphql
```

Then, pick your preferred runtime:

### Binary

See [GitHub Releases](https://github.com/graphql-hive/gateway-rs/releases) and use the artifacts published to each release.
Then, run the router:

```bash
# By default, "hive-router.config.yaml" is used for configuration. Override it by setting "HIVE_CONFIG_FILE_PATH=some-custom-file.yaml"
# If you are using env vars, make sure to set the variables before running the gateway.
./gateway
# If you are using env vars, make sure to set the variables before running the router.
./hive_router
```

### Binary

See [GitHub Releases](https://github.com/graphql-hive/router/releases) to the full list of release and versions.

### Docker

The router image is being published to [Docker to GitHub Container Registry](). You may use it directly using the following command:
Expand Down
10 changes: 5 additions & 5 deletions audits/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading