Skip to content

Commit

Permalink
router-bridge: Update to now-published federation 2.1.0 packages (#161)
Browse files Browse the repository at this point in the history
> Note: This merges into `abernix/router-bridge-direct-deps` #160, which itself merges into #159 

Ref: apollographql/federation#2105
  • Loading branch information
Geal committed Aug 30, 2022
2 parents 91bc980 + 1623bc9 commit 9e9ef90
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 61 deletions.
38 changes: 38 additions & 0 deletions federation-2/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 federation-2/router-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ uuid = { version = "0.8.2", features = ["v4", "serde"] }
[dev-dependencies]
futures = "0.3.21"
insta = "1.8.0"
pretty_assertions = "1.2.1"
tracing-test = "0.2.1"

[build-dependencies]
Expand Down
17 changes: 12 additions & 5 deletions federation-2/router-bridge/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ use std::path::{Path, PathBuf};
use std::process::Command;

fn main() {
let out_dir: PathBuf = std::env::var_os("OUT_DIR")
.expect("$OUT_DIR not set.")
.into();
println!("cargo:rerun-if-changed=js-src");
let current_dir = std::env::current_dir().unwrap();
// only do `npm` related stuff if we're _not_ publishing to crates.io
if std::fs::metadata("./package.json").is_ok() {
println!("cargo:rerun-if-changed=js-src");

let current_dir = std::env::current_dir().unwrap();

update_bridge(&current_dir);
} else {
// the crate has been published, no need to rerun
println!("cargo:rerun-if-changed=build.rs");
}

let out_dir: PathBuf = std::env::var_os("OUT_DIR")
.expect("$OUT_DIR not set.")
.into();

create_snapshot(&out_dir);
}

Expand Down
4 changes: 2 additions & 2 deletions federation-2/router-bridge/js-src/introspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function batchIntrospect(
let composedSchema = buildSchema(sdl);
let apiSchema = composedSchema.toAPISchema();
schema = apiSchema.toGraphQLJSSchema({
includeDefer: options.deferStreamSupport?.enableDefer,
includeDefer: options.incrementalDelivery?.enableDefer,
});
} catch (e) {
return Array(queries.length).fill({
Expand Down Expand Up @@ -52,7 +52,7 @@ export function introspect(
let composedSchema = buildSchema(sdl);
let apiSchema = composedSchema.toAPISchema();
schema = apiSchema.toGraphQLJSSchema({
includeDefer: options.deferStreamSupport?.enableDefer,
includeDefer: options.incrementalDelivery?.enableDefer,
});
} catch (e) {
return {
Expand Down
2 changes: 1 addition & 1 deletion federation-2/router-bridge/js-src/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class BridgeQueryPlanner {
this.composedSchema = schema;
const apiSchema = this.composedSchema.toAPISchema();
this.apiSchema = apiSchema.toGraphQLJSSchema({
includeDefer: options.deferStreamSupport?.enableDefer,
includeDefer: options.incrementalDelivery?.enableDefer,
});
this.planner = new QueryPlanner(this.composedSchema, options);
}
Expand Down
58 changes: 28 additions & 30 deletions federation-2/router-bridge/package-lock.json

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

6 changes: 3 additions & 3 deletions federation-2/router-bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@apollo/router-bridge",
"private": true,
"version": "2.0.0-alpha.6",
"version": "2.1.0",
"description": "Apollo Router JS Bridge Entrypoint",
"scripts": {
"build": "make-dir bundled js-dist && rm -f tsconfig.tsbuildinfo && tsc --build --verbose && node esbuild/bundler.js && cp js-dist/runtime.js js-dist/do_api_schema.js js-dist/do_introspect.js js-dist/plan_worker.js js-dist/test_logger_worker.js bundled/",
Expand All @@ -28,8 +28,8 @@
},
"dependencies": {
"@apollo/core-schema": "^0.3.0",
"@apollo/federation-internals": "2.1.0-alpha.4",
"@apollo/query-planner": "2.1.0-alpha.4",
"@apollo/federation-internals": "2.1.0",
"@apollo/query-planner": "2.1.0",
"@apollo/utils.usagereporting": "^1.0.0",
"apollo-reporting-protobuf": "^3.3.1",
"fast-text-encoding": "1.0.3",
Expand Down
8 changes: 4 additions & 4 deletions federation-2/router-bridge/src/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ pub fn batch_introspect(
mod tests {
use crate::{
introspect::batch_introspect,
planner::{DeferStreamSupport, QueryPlannerConfig},
planner::{IncrementalDeliverySupport, QueryPlannerConfig},
};
#[test]
fn it_works() {
let raw_sdl = r#"schema
{
query: Query
}
type Query {
hello: String
}
Expand Down Expand Up @@ -220,7 +220,7 @@ fragment FullType on __Type {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
Expand Down Expand Up @@ -304,7 +304,7 @@ fragment TypeRef on __Type {
}"#
.to_string()],
QueryPlannerConfig {
defer_stream_support: Some(DeferStreamSupport {
incremental_delivery: Some(IncrementalDeliverySupport {
enable_defer: Some(true),
}),
},
Expand Down
Loading

0 comments on commit 9e9ef90

Please sign in to comment.