Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
000ce68
napi new
enisdenjo Oct 13, 2025
6aa0d25
profiles at root
enisdenjo Oct 13, 2025
ced3c2c
build
enisdenjo Oct 13, 2025
e30b5d0
qp v1
enisdenjo Oct 13, 2025
5cc5b44
tokio future and build
enisdenjo Oct 13, 2025
ac66030
test
enisdenjo Oct 13, 2025
9496845
should it be async
enisdenjo Oct 13, 2025
4107f50
todo
enisdenjo Oct 13, 2025
aac4852
what am I doing?
enisdenjo Oct 13, 2025
89c0a62
just use serde
enisdenjo Oct 14, 2025
fba1e08
explain
enisdenjo Oct 14, 2025
5cee399
async and use workspace libs
enisdenjo Oct 14, 2025
318dfcf
sophisticated test
enisdenjo Oct 14, 2025
b562450
sync plan for testing
enisdenjo Oct 14, 2025
06e998d
check node addon doc
enisdenjo Oct 16, 2025
2375c2f
test snapshot
enisdenjo Oct 17, 2025
98ff70f
convert to include operation document node
enisdenjo Oct 14, 2025
c3d9e0c
fetch node can be nested
enisdenjo Oct 16, 2025
d8b0dab
use btreeset too
enisdenjo Oct 16, 2025
7df97e5
no sync, async hella fast
enisdenjo Oct 17, 2025
785fb55
custom serializer for op doc node
enisdenjo Oct 17, 2025
c3200b1
optimization pass
enisdenjo Oct 17, 2025
0d9f99a
faster anyways
enisdenjo Oct 17, 2025
bf1c11d
bump napi-rs and start rework
enisdenjo Oct 21, 2025
5516278
bump and fix build
enisdenjo Oct 21, 2025
b67364c
build js with esm
enisdenjo Oct 21, 2025
d319ead
query plan type defs
enisdenjo Oct 21, 2025
0ea6de5
tests and compile
enisdenjo Oct 21, 2025
daef289
create fixtures
enisdenjo Oct 21, 2025
4741cd4
simple inaccessible fixture
enisdenjo Oct 21, 2025
1f6e3ba
consumer schema
enisdenjo Oct 24, 2025
60661c5
fix typedefs for flatten node path
enisdenjo Oct 24, 2025
e109413
no string, just @
enisdenjo Oct 24, 2025
cdb9239
actual correct paths not normalized ones in js
enisdenjo Oct 24, 2025
c9ac225
correct rewrites
enisdenjo Oct 26, 2025
552bf5e
alight completely
enisdenjo Oct 26, 2025
f2449d0
match targets and bundle everytthing
enisdenjo Oct 26, 2025
0825b26
hive_router.node
enisdenjo Oct 26, 2025
90807fc
build node addon
enisdenjo Oct 26, 2025
2a43199
npm ci npm run build
enisdenjo Oct 26, 2025
1ba71b2
cheers clippy
enisdenjo Oct 26, 2025
7db9899
named builds
enisdenjo Oct 26, 2025
35ea82e
build on target
enisdenjo Oct 26, 2025
8307d40
no fail fast
enisdenjo Oct 26, 2025
e1b38cf
build in binary
enisdenjo Oct 26, 2025
4adb051
test node-addon too
enisdenjo Oct 26, 2025
b59ca2e
no space
enisdenjo Oct 26, 2025
abd3ab8
actually cross compile
enisdenjo Oct 26, 2025
b496b84
name it
enisdenjo Oct 26, 2025
d8d9cfc
node version 24 for node-addon
enisdenjo Oct 26, 2025
b4dccb3
trim ok
enisdenjo Oct 26, 2025
3f8b5d5
node-addon release plz
enisdenjo Oct 26, 2025
5ef4822
version 0.0.0
enisdenjo Oct 26, 2025
048dfae
more info in pkg json
enisdenjo Oct 26, 2025
c2c5d01
public package
enisdenjo Oct 26, 2025
6ac8247
fix docker artfiacts
enisdenjo Oct 26, 2025
7845840
rename node-addon
enisdenjo Oct 31, 2025
7c1d197
rename in lockfile
enisdenjo Oct 31, 2025
d05bb96
Merge branch 'main' into napi
enisdenjo Nov 4, 2025
5c966cf
add node addon to knope
enisdenjo Nov 4, 2025
d23f3d0
changelog
enisdenjo Nov 4, 2025
78950c4
no lockfile
enisdenjo Nov 4, 2025
df60994
node addon scope
enisdenjo Nov 4, 2025
d96b1af
changeset
enisdenjo Nov 4, 2025
3ffbf52
artifacts in right places
enisdenjo Nov 5, 2025
4c9295b
Merge branch 'main' into napi
enisdenjo Nov 5, 2025
9652a41
better changeset
enisdenjo Nov 5, 2025
73f5fdb
readme of course
enisdenjo Nov 5, 2025
7a01a8a
build on release and push to node addon
enisdenjo Nov 5, 2025
a8f284d
npm publish job
enisdenjo Nov 5, 2025
7eb7a6c
prepare artifacts
enisdenjo Nov 5, 2025
22b5349
simpler node addon name and stuff
enisdenjo Nov 5, 2025
edf31a1
ok sorry
enisdenjo Nov 5, 2025
7500d98
explain
enisdenjo Nov 5, 2025
3a19f12
grape release
enisdenjo Nov 5, 2025
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
51 changes: 51 additions & 0 deletions .changeset/this_is_first_release_ever.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
node-addon: minor
---

# A node addon containing the query planner of hive router

To use in TypeScript, you would go ahead and do something like:

```ts
import {
QueryPlanner,
type QueryPlan,
} from "@graphql-hive/router-query-planner";

const supergraphSdl = "<your sdl from file or in code>";

const qp = new QueryPlanner(supergraphSdl);

const plan: QueryPlan = qp.plan(/* GraphQL */ `
{
posts {
title
author {
name
}
}
}
`);

// see QueryPlan types in lib/node-addon/src/query-plan.d.ts
```

which will generate you a [Query Plan used in Apollo Federation](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/reference/query-plans).

Hive Gateway uses it as an alternative federation query planner in the [`@graphql-hive/router-runtime`](https://github.com/graphql-hive/gateway/blob/main/packages/router-runtime).

To use in with Hive Gateway, you first install the runtime

```sh
npm i @graphql-hive/router-runtime
```

```ts
// gateway.config.ts
import { defineConfig } from "@graphql-hive/gateway";
import { unifiedGraphHandler } from "@graphql-hive/router-runtime";

export const gatewayConfig = defineConfig({
unifiedGraphHandler,
});
```
76 changes: 71 additions & 5 deletions .github/workflows/build-router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ jobs:

binary:
name: ${{ matrix.name }}
if: github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'router/v'))
if: |
github.event_name == 'push' || github.event_name == 'pull_request' || (
github.event_name == 'release' &&
(
startsWith(github.event.release.tag_name, 'router/v') ||
startsWith(github.event.release.tag_name, 'node-addon/v')
)
)
runs-on: ${{ matrix.action_runner }}
strategy:
matrix:
Expand Down Expand Up @@ -112,19 +119,78 @@ jobs:
if: ${{ !matrix.zigbuild }}

- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
name: upload build artifact
name: upload router artifact
with:
name: hive_router_${{ matrix.name }}
path: target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
path: |
target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
if-no-files-found: error

# napi build will use zigbuild when cross compiling
- name: node-addon build (${{ matrix.rust_target }})
working-directory: lib/node-addon
env:
CROSS_COMPILE: ${{ matrix.zigbuild }}
TARGET: ${{ matrix.rust_target }}
run: |
npm ci
npm run build
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
name: upload node addon artifact
with:
name: node_addon_${{ matrix.name }}
path: |
lib/node-addon/*.node
if-no-files-found: error
- name: Upload binaries to release

- name: Upload binaries to router release
uses: svenstaro/upload-release-action@81c65b7cd4de9b2570615ce3aad67a41de5b1a13 # v2
if: ${{ github.event_name == 'release' }}
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'router/v')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.rust_target }}/release/${{ env.BINARY_NAME }}
asset_name: hive_router_${{ matrix.name }}
tag: ${{ github.ref }}
- name: Upload node addons to release
uses: svenstaro/upload-release-action@81c65b7cd4de9b2570615ce3aad67a41de5b1a13 # v2
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'node-addon/v')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: lib/node-addon/*.node
tag: ${{ github.ref }}

# NOTE: would publish from release.yaml but we need the artifacts. doing it from here is simpler
npm-publish:
name: publish node addon
runs-on: ubuntu-latest
needs:
- binary
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'node-addon/v')
steps:
- name: checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: setup node
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
node-version-file: lib/node-addon/.node-version
registry-url: https://registry.npmjs.org
- name: download node addon artifacts
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
with:
pattern: node_addon_*
path: lib/node-addon
- name: prepare artifacts
working-directory: lib/node-addon
run: |
mv ./node_addon_linux_arm64/* .
mv ./node_addon_linux_amd64/* .
mv ./node_addon_macos_arm64/* .
mv ./node_addon_macos_amd64/* .
- name: npm publish
working-directory: lib/node-addon
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --provenance

docker:
runs-on: ubuntu-latest
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ jobs:
env:
RUST_BACKTRACE: full
RUST_LOG: debug
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
node-version-file: lib/node-addon/.node-version
- name: node-addon test
working-directory: lib/node-addon
run: |
npm ci
npm run build:debug
npm test

build-release:
name: cargo build
Expand Down
127 changes: 127 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"lib/query-planner",
"lib/router-config",
"lib/executor",
"lib/node-addon",
"bin/dev-cli",
"bin/router",
"e2e",
Expand Down
5 changes: 5 additions & 0 deletions knope.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ versioned_files = ["bin/router/Cargo.toml", "Cargo.lock"]
scopes = ["hive-router", "router", "config", "qp", "executor"]
changelog = "bin/router/CHANGELOG.md"

[packages.node-addon]
versioned_files = ["lib/node-addon/package.json"]
scopes = ["node-addon"]
changelog = "lib/node-addon/CHANGELOG.md"

# "release" pipeline that prepares the release and pushes a release PR
[[workflows]]
name = "release"
Expand Down
2 changes: 2 additions & 0 deletions lib/node-addon/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
1 change: 1 addition & 0 deletions lib/node-addon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.node
1 change: 1 addition & 0 deletions lib/node-addon/.node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v24
2 changes: 2 additions & 0 deletions lib/node-addon/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
index.js
index.d.ts
1 change: 1 addition & 0 deletions lib/node-addon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @graphql-hive/router-query-planner changelog
23 changes: 23 additions & 0 deletions lib/node-addon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
edition = "2021"
version = "0.0.0"
name = "node-addon"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
hive-router-query-planner = { path = "../query-planner", version = "2.0.0" }
tokio = { workspace = true }
serde_json = { workspace = true }
napi = { version = "3.0.0", features = ["async", "serde-json"] }
napi-derive = "3.0.0"

[build-dependencies]
napi-build = "2"

# TODO: profiles need to specified at root Cargo.toml, does it make a difference? I see lto is true there too
# [profile.release]
# lto = true
# strip = "symbols"
Loading
Loading