Skip to content
Merged
Changes from all commits
Commits
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
153 changes: 0 additions & 153 deletions apollo-federation/src/subgraph/typestate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,156 +894,3 @@ mod tests {
);
}
}

// PORT_NOTE: Corresponds to '@core/@link handling' tests in JS
#[cfg(test)]
mod link_handling_tests {
use super::*;

// TODO(FED-543): Remaining directive definitions should be added to the schema
#[allow(dead_code)]
const EXPECTED_FULL_SCHEMA: &str = r#"
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"])
{
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 @federation__requires(fields: federation__FieldSet!) on FIELD_DEFINITION

directive @federation__provides(fields: federation__FieldSet!) on FIELD_DEFINITION

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

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

directive @federation__extends on OBJECT | INTERFACE

directive @federation__shareable on OBJECT | FIELD_DEFINITION

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

directive @federation__override(from: String!) on FIELD_DEFINITION

type T
@key(fields: "k")
{
k: ID!
}

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 _Any

type _Service {
sdl: String
}

union _Entity = T

type Query {
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
}
"#;

#[test]
fn expands_everything_if_only_the_federation_spec_is_linked() {
let subgraph = Subgraph::parse(
"S",
"",
r#"
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"])

type T @key(fields: "k") {
k: ID!
}
"#,
)
.expect("valid schema")
.expand_links()
.expect("expands subgraph")
.validate(true)
.expect("expanded subgraph to be valid");

// TODO(FED-543): `subgraph` is supposed to be compared against `EXPECTED_FULL_SCHEMA`, but
// it's failing due to missing directive definitions. So, we use
// `insta::assert_snapshot` for now.
// assert_eq!(subgraph.schema().schema().to_string(), EXPECTED_FULL_SCHEMA);
insta::assert_snapshot!(subgraph.schema().schema().to_string(), @r###"
schema @link(url: "https://specs.apollo.dev/link/v1.0") {
query: Query
}

extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"])

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 @federation__requires(fields: federation__FieldSet!) on FIELD_DEFINITION

directive @federation__provides(fields: federation__FieldSet!) on FIELD_DEFINITION

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

directive @federation__shareable on OBJECT | FIELD_DEFINITION

directive @federation__override(from: String!) on FIELD_DEFINITION

directive @federation__tag repeatable on ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

type T @key(fields: "k") {
k: ID!
}

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 _Any

type _Service {
sdl: String
}

union _Entity = T

type Query {
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
}
"###);
}
}