Revert "default to printing the applicaiton of the link directive"

This reverts commit 393184a23c.
This commit is contained in:
aidan coyne 2022-09-22 09:48:10 -05:00
parent 393184a23c
commit 2803cf3128
7 changed files with 16 additions and 22 deletions

View File

@ -112,7 +112,7 @@ impl Registry {
}
if options.federation {
if !self.suppress_apollo_link {
if self.enable_apollo_link {
writeln!(sdl, "extend schema @link(").ok();
writeln!(sdl, "\turl: \"https://specs.apollo.dev/federation/v2.0\",").ok();
writeln!(sdl, "\timport: [\"@key\", \"@tag\", \"@shareable\", \"@inaccessible\", \"@override\", \"@external\", \"@provides\", \"@requires\"]").ok();

View File

@ -423,7 +423,7 @@ pub struct Registry {
pub subscription_type: Option<String>,
pub introspection_mode: IntrospectionMode,
pub enable_federation: bool,
pub suppress_apollo_link: bool,
pub enable_apollo_link: bool,
pub federation_subscription: bool,
pub ignore_name_conflicts: HashSet<String>,
}

View File

@ -173,13 +173,13 @@ impl<Query, Mutation, Subscription> SchemaBuilder<Query, Mutation, Subscription>
self
}
/// By default, schema export in the federation mode will now automatically
/// print out a `@link` directive attached to an `extend schema`
/// element. If you need to prevent this printing for any reason, you
/// can use this method to prevent that printing.
/// Enables printing the apollo federation 2 `@link` directive during
/// federation schema export; the directive is attached to an "extend
/// schema" element, and will have values set to ensure that
/// the federation schema directives and types are named properly.
#[must_use]
pub fn suppress_apollo_link(mut self) -> Self {
self.registry.suppress_apollo_link = true;
pub fn enable_apollo_fed2_link(mut self) -> Self {
self.registry.enable_apollo_link = true;
self
}
@ -389,7 +389,7 @@ where
},
introspection_mode: IntrospectionMode::Enabled,
enable_federation: false,
suppress_apollo_link: false,
enable_apollo_link: false,
federation_subscription: false,
ignore_name_conflicts,
};

View File

@ -547,10 +547,8 @@ pub async fn test_entity_inaccessible() {
}
}
// tests suppressing the link directive. note that test_entity_inaccessible and
// test_entity_tag now verify the default printing of the link directive.
#[tokio::test]
pub async fn test_suppress_link_directive() {
pub async fn test_link_directive() {
struct User {
id: ID,
}
@ -616,12 +614,12 @@ pub async fn test_suppress_link_directive() {
}
let schema_sdl = Schema::build(Query, EmptyMutation, EmptySubscription)
.suppress_apollo_link()
.enable_apollo_fed2_link()
.finish()
.sdl_with_options(SDLExportOptions::new().federation());
let path = std::path::Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap())
.join("tests/schemas/test_suppress_link.graphqls");
.join("tests/schemas/test_fed2_link.schema.graphqls");
let expected_schema = std::fs::read_to_string(&path).unwrap();
if schema_sdl != expected_schema {
std::fs::write(path, schema_sdl).unwrap();

View File

@ -65,7 +65,3 @@ extend type Query {
}
extend schema @link(
url: "https://specs.apollo.dev/federation/v2.0",
import: ["@key", "@tag", "@shareable", "@inaccessible", "@override", "@external", "@provides", "@requires"]
)

View File

@ -65,7 +65,3 @@ extend type Query {
}
extend schema @link(
url: "https://specs.apollo.dev/federation/v2.0",
import: ["@key", "@tag", "@shareable", "@inaccessible", "@override", "@external", "@provides", "@requires"]
)

View File

@ -20,3 +20,7 @@ extend type User @key(fields: "id") {
reviews: [Review!]!
}
extend schema @link(
url: "https://specs.apollo.dev/federation/v2.0",
import: ["@key", "@tag", "@shareable", "@inaccessible", "@override", "@external", "@provides", "@requires"]
)