Skip to content

Commit

Permalink
Use separate snapshots for each subgraph in extract test
Browse files Browse the repository at this point in the history
  • Loading branch information
tninesling committed Aug 26, 2024
1 parent 4cf29eb commit 837f731
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 110 deletions.
13 changes: 2 additions & 11 deletions router-bridge/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2475,17 +2475,8 @@ feature https://specs.apollo.dev/unsupported-feature/v0.1 is for: SECURITY but i
.expect("can create planner");
let subgraphs = planner.subgraphs().await.expect("can extract subgraphs");

let mut snapshot = String::new();
for name in vec!["subgraphWithCost", "subgraphWithListSize"] {
use std::fmt::Write;

let sdl = subgraphs.get(name).unwrap();
_ = writeln!(
&mut snapshot,
"--------------------\n{}\n--------------------\n{}",
name, sdl
);
for (name, schema) in subgraphs {
insta::assert_snapshot!(name, schema);
}
insta::assert_snapshot!(snapshot);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
source: router-bridge/src/planner.rs
expression: snapshot
expression: schema
---
--------------------
subgraphWithCost
--------------------
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"])
Expand Down Expand Up @@ -113,98 +110,3 @@ scalar _Any
type _Service {
sdl: String
}
--------------------
subgraphWithListSize
--------------------
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
}
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
}

0 comments on commit 837f731

Please sign in to comment.