Skip to content

Commit

Permalink
Automated PR for router-bridge release 2.9.0 (#570)
Browse files Browse the repository at this point in the history
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

---------

Co-authored-by: apollo-bot2 <apollo-bot2@users.noreply.github.com>
Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>
Co-authored-by: Taylor Ninesling <taylor.ninesling@gmail.com>
Co-authored-by: Taylor Ninesling <taylor.ninesling@apollographql.com>
  • Loading branch information
5 people authored Aug 27, 2024
1 parent d93bc39 commit 81f1ca7
Show file tree
Hide file tree
Showing 16 changed files with 618 additions and 130 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion router-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "router-bridge"
version = "0.5.31+v2.8.5"
version = "0.6.0+v2.9.0"
authors = ["Apollo <packages@apollographql.com>"]
edition = "2018"
description = "JavaScript bridge for the Apollo Router"
Expand Down
3 changes: 2 additions & 1 deletion router-bridge/js-src/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import {
Operation,
operationFromDocument,
printSchema as printSchemaWithDirectives,
Supergraph,
} from "@apollo/federation-internals";
import {
Expand Down Expand Up @@ -281,7 +282,7 @@ export class BridgeQueryPlanner {
let result = new Map<string, string>();

subgraphs.names().forEach((name) => {
let sdl = printSchema(subgraphs.get(name).schema.toGraphQLJSSchema({}));
let sdl = printSchemaWithDirectives(subgraphs.get(name).schema);
result.set(name, sdl);
});

Expand Down
2 changes: 2 additions & 0 deletions router-bridge/js-src/supported_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
REQUIRES_SCOPES_VERSIONS,
SOURCE_VERSIONS,
CONTEXT_VERSIONS,
COST_VERSIONS,
} from "@apollo/federation-internals";

export const ROUTER_SUPPORTED_SUPERGRAPH_FEATURES: Set<string> = new Set(
Expand All @@ -32,3 +33,4 @@ addToRouterFeatures(REQUIRES_SCOPES_VERSIONS);
addToRouterFeatures(POLICY_VERSIONS);
addToRouterFeatures(SOURCE_VERSIONS);
addToRouterFeatures(CONTEXT_VERSIONS);
addToRouterFeatures(COST_VERSIONS);
32 changes: 16 additions & 16 deletions 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 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.8.5",
"version": "2.9.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 js-dist/test_get_random_values.js js-dist/test_url.js bundled/",
Expand All @@ -28,8 +28,8 @@
},
"dependencies": {
"@apollo/core-schema": "^0.3.0",
"@apollo/federation-internals": "^2.8.5",
"@apollo/query-planner": "^2.8.5",
"@apollo/federation-internals": "^2.9.0",
"@apollo/query-planner": "^2.9.0",
"@apollo/usage-reporting-protobuf": "^4.0.0",
"@apollo/utils.usagereporting": "^3.0.0",
"graphql": "16.6.0"
Expand Down
13 changes: 13 additions & 0 deletions router-bridge/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2466,4 +2466,17 @@ feature https://specs.apollo.dev/unsupported-feature/v0.1 is for: SECURITY but i
)
.unwrap());
}

#[tokio::test]
async fn extracts_cost_directives() {
let schema = include_str!("testdata/custom_cost_schema.graphql");
let planner = Planner::<serde_json::Value>::new(schema.to_string(), Default::default())
.await
.expect("can create planner");
let subgraphs = planner.subgraphs().await.expect("can extract subgraphs");

for (name, schema) in subgraphs {
insta::assert_snapshot!(name, schema);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
source: router-bridge/src/planner.rs
expression: schema
---
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"])
{
query: Query
}

directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @requires(fields: federation__FieldSet!) on FIELD_DEFINITION

directive @provides(fields: federation__FieldSet!) on FIELD_DEFINITION

directive @external(reason: String) on OBJECT | FIELD_DEFINITION

directive @tag(name: String!) repeatable on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA

directive @extends on OBJECT | INTERFACE

directive @shareable repeatable on OBJECT | FIELD_DEFINITION

directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

directive @override(from: String!, label: String) on FIELD_DEFINITION

directive @composeDirective(name: String) repeatable on SCHEMA

directive @interfaceObject on OBJECT

directive @federation__authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM

directive @federation__requiresScopes(scopes: [[federation__Scope!]!]!) on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM

directive @federation__policy(policies: [[federation__Policy!]!]!) on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM

directive @federation__sourceAPI repeatable on SCHEMA

directive @federation__sourceType repeatable on OBJECT | INTERFACE

directive @federation__sourceField repeatable on FIELD_DEFINITION

directive @federation__context(name: String!) repeatable on INTERFACE | OBJECT | UNION

directive @federation__fromContext(field: federation__ContextFieldValue) on ARGUMENT_DEFINITION

directive @federation__cost(weight: Int!) on ARGUMENT_DEFINITION | ENUM | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | OBJECT | SCALAR

directive @federation__listSize(assumedSize: Int, slicingArguments: [String!], sizedFields: [String!], requireOneSlicingArgument: Boolean = true) on FIELD_DEFINITION

enum link__Purpose {
"""
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
EXECUTION
}

scalar link__Import

scalar federation__FieldSet

scalar federation__Scope

scalar federation__Policy

scalar federation__ContextFieldValue

enum AorB
@federation__cost(weight: 15)
{
A
B
}

scalar ExpensiveInt
@federation__cost(weight: 30)

type ExpensiveObject
@federation__cost(weight: 40)
{
id: ID
}

input InputTypeWithCost {
somethingWithCost: Int @federation__cost(weight: 20)
}

type Query {
fieldWithCost: Int @federation__cost(weight: 5)
argWithCost(arg: Int @federation__cost(weight: 10)): Int
enumWithCost: AorB
inputWithCost(someInput: InputTypeWithCost): Int
scalarWithCost: ExpensiveInt
objectWithCost: ExpensiveObject
_service: _Service!
}

scalar _Any

type _Service {
sdl: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
source: router-bridge/src/planner.rs
expression: schema
---
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"])
{
query: Query
}

directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA

directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE

directive @requires(fields: federation__FieldSet!) on FIELD_DEFINITION

directive @provides(fields: federation__FieldSet!) on FIELD_DEFINITION

directive @external(reason: String) on OBJECT | FIELD_DEFINITION

directive @tag(name: String!) repeatable on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA

directive @extends on OBJECT | INTERFACE

directive @shareable repeatable on OBJECT | FIELD_DEFINITION

directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

directive @override(from: String!, label: String) on FIELD_DEFINITION

directive @composeDirective(name: String) repeatable on SCHEMA

directive @interfaceObject on OBJECT

directive @federation__authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM

directive @federation__requiresScopes(scopes: [[federation__Scope!]!]!) on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM

directive @federation__policy(policies: [[federation__Policy!]!]!) on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM

directive @federation__sourceAPI repeatable on SCHEMA

directive @federation__sourceType repeatable on OBJECT | INTERFACE

directive @federation__sourceField repeatable on FIELD_DEFINITION

directive @federation__context(name: String!) repeatable on INTERFACE | OBJECT | UNION

directive @federation__fromContext(field: federation__ContextFieldValue) on ARGUMENT_DEFINITION

directive @federation__cost(weight: Int!) on ARGUMENT_DEFINITION | ENUM | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | OBJECT | SCALAR

directive @federation__listSize(assumedSize: Int, slicingArguments: [String!], sizedFields: [String!], requireOneSlicingArgument: Boolean = true) on FIELD_DEFINITION

enum link__Purpose {
"""
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
EXECUTION
}

scalar link__Import

scalar federation__FieldSet

scalar federation__Scope

scalar federation__Policy

scalar federation__ContextFieldValue

type A {
id: ID
}

type Query {
fieldWithListSize: [String!] @federation__listSize(assumedSize: 2000, requireOneSlicingArgument: false)
fieldWithDynamicListSize(first: Int = 10): SizedField @federation__listSize(slicingArguments: ["first"], sizedFields: ["items"], requireOneSlicingArgument: true)
_service: _Service!
}

type SizedField {
items: [A]
}

scalar _Any

type _Service {
sdl: String
}
Loading

0 comments on commit 81f1ca7

Please sign in to comment.