Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8414be2
napi new
enisdenjo Oct 13, 2025
3323d36
profiles at root
enisdenjo Oct 13, 2025
bc5ab26
build
enisdenjo Oct 13, 2025
097a6b5
qp v1
enisdenjo Oct 13, 2025
ce20ecb
tokio future and build
enisdenjo Oct 13, 2025
dcec1ac
test
enisdenjo Oct 13, 2025
00b35ee
should it be async
enisdenjo Oct 13, 2025
121fbc7
todo
enisdenjo Oct 13, 2025
90e1d93
what am I doing?
enisdenjo Oct 13, 2025
a9bf05b
just use serde
enisdenjo Oct 14, 2025
d6d638e
explain
enisdenjo Oct 14, 2025
30bc3a8
async and use workspace libs
enisdenjo Oct 14, 2025
19d5290
sophisticated test
enisdenjo Oct 14, 2025
aefce1b
sync plan for testing
enisdenjo Oct 14, 2025
16e60f8
check node addon doc
enisdenjo Oct 16, 2025
6b4511c
test snapshot
enisdenjo Oct 17, 2025
a512232
convert to include operation document node
enisdenjo Oct 14, 2025
0d56be4
fetch node can be nested
enisdenjo Oct 16, 2025
508486f
use btreeset too
enisdenjo Oct 16, 2025
32ba3cc
no sync, async hella fast
enisdenjo Oct 17, 2025
59feb74
custom serializer for op doc node
enisdenjo Oct 17, 2025
f5b7e2d
optimization pass
enisdenjo Oct 17, 2025
e590caa
faster anyways
enisdenjo Oct 17, 2025
b4565c2
bump napi-rs and start rework
enisdenjo Oct 21, 2025
36d60f4
bump and fix build
enisdenjo Oct 21, 2025
29225c5
build js with esm
enisdenjo Oct 21, 2025
536dc6f
query plan type defs
enisdenjo Oct 21, 2025
3c78bc6
tests and compile
enisdenjo Oct 21, 2025
9a3c6b1
create fixtures
enisdenjo Oct 21, 2025
df7dc10
simple inaccessible fixture
enisdenjo Oct 21, 2025
8eec52d
consumer schema
enisdenjo Oct 24, 2025
219c465
fix typedefs for flatten node path
enisdenjo Oct 24, 2025
4f17689
no string, just @
enisdenjo Oct 24, 2025
78c13fd
actual correct paths not normalized ones in js
enisdenjo Oct 24, 2025
ab33592
correct rewrites
enisdenjo Oct 26, 2025
a81d26a
alight completely
enisdenjo Oct 26, 2025
ae9e30e
match targets and bundle everytthing
enisdenjo Oct 26, 2025
e50bc23
hive_router.node
enisdenjo Oct 26, 2025
a210463
build node addon
enisdenjo Oct 26, 2025
10e4773
npm ci npm run build
enisdenjo Oct 26, 2025
88e3f46
cheers clippy
enisdenjo Oct 26, 2025
e13f5a0
named builds
enisdenjo Oct 26, 2025
b162882
build on target
enisdenjo Oct 26, 2025
ecb5290
no fail fast
enisdenjo Oct 26, 2025
b4d8e37
build in binary
enisdenjo Oct 26, 2025
1e300ef
test node-addon too
enisdenjo Oct 26, 2025
abdbccc
no space
enisdenjo Oct 26, 2025
03ff1d6
actually cross compile
enisdenjo Oct 26, 2025
0eca24e
name it
enisdenjo Oct 26, 2025
5bc8494
node version 24 for node-addon
enisdenjo Oct 26, 2025
dee6d8d
trim ok
enisdenjo Oct 26, 2025
a03d2a2
node-addon release plz
enisdenjo Oct 26, 2025
cb649f4
version 0.0.0
enisdenjo Oct 26, 2025
e39e64f
more info in pkg json
enisdenjo Oct 26, 2025
f9542ee
public package
enisdenjo Oct 26, 2025
2b33381
fix docker artfiacts
enisdenjo Oct 26, 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
25 changes: 22 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,23 @@ jobs:
run: cargo build --release --target ${{ matrix.rust_target }}
if: ${{ !matrix.zigbuild }}

# 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 build 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 }}
lib/node-addon/${{ env.BINARY_NAME }}.*.node
if-no-files-found: error
- name: Upload binaries to release
uses: svenstaro/upload-release-action@81c65b7cd4de9b2570615ce3aad67a41de5b1a13 # v2
Expand All @@ -125,6 +137,13 @@ jobs:
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' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: lib/node-addon/${{ env.BINARY_NAME }}.*.node
tag: ${{ github.ref }}

docker:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -163,8 +182,8 @@ jobs:
mkdir -p ./target/linux/arm64
mkdir -p ./target/linux/amd64

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 }}
mv ./artifacts/target/aarch64-unknown-linux-gnu/release/${{ env.BINARY_NAME }} ./target/linux/arm64/${{ env.BINARY_NAME }}
mv ./artifacts/target/x86_64-unknown-linux-gnu/release/${{ env.BINARY_NAME }} ./target/linux/amd64/${{ env.BINARY_NAME }}
ls -ltra ./target/linux/arm64/
ls -ltra ./target/linux/amd64/
- uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
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 @@ -4,6 +4,7 @@ members = [
"lib/router-config",
"lib/wasm-lib",
"lib/executor",
"lib/node-addon",
"bin/dev-cli",
"bin/router",
"e2e",
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
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"
30 changes: 30 additions & 0 deletions lib/node-addon/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { NapiCli } from "@napi-rs/cli";
import fs from "node:fs/promises";

const cli = new NapiCli();

const release = process.env["RELEASE"] === "true";
const crossCompile = process.env["CROSS_COMPILE"] === "true";

(async function build() {
const target = process.env["TARGET"];
console.log(
`Building node-addon in ${release ? "release" : "debug"} mode for ${
target || "current os and arch"
}${crossCompile ? " with cross compile" : ""}...`
);
const { task } = await cli.build({
release,
platform: true,
esm: true,
crossCompile,
target,
});
await task;

console.log("Adding QueryPlan definitions...");
const queryPlanTypeDefs = await fs.readFile("src/query-plan.d.ts", "utf8");
await fs.appendFile("index.d.ts", `\n${queryPlanTypeDefs}`);

console.log("Ok");
})();
3 changes: 3 additions & 0 deletions lib/node-addon/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
napi_build::setup();
}
58 changes: 58 additions & 0 deletions lib/node-addon/fixture/federation-example/query.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
fragment User on User {
id
username
name
}

fragment Review on Review {
id
body
}

fragment Product on Product {
inStock
name
price
shippingEstimate
upc
weight
}

query TestQuery {
users {
...User
reviews {
...Review
product {
...Product
reviews {
...Review
author {
...User
reviews {
...Review
product {
...Product
}
}
}
}
}
}
}
topProducts {
...Product
reviews {
...Review
author {
...User
reviews {
...Review
product {
...Product
}
}
}
}
}
}
Loading
Loading