diff --git a/.changesets/fix_customer_snore_infant_wrap.md b/.changesets/fix_customer_snore_infant_wrap.md new file mode 100644 index 0000000000..ead868d4de --- /dev/null +++ b/.changesets/fix_customer_snore_infant_wrap.md @@ -0,0 +1,5 @@ +### Allow to use progressive override with federation 2.7 and above ([PR #5754](https://github.com/apollographql/router/pull/5754)) + +The progressive override feature is now properly available using federation 2.7 and above. + +By [@o0ignition0o](https://github.com/o0ignition0o) in https://github.com/apollographql/router/pull/5754 diff --git a/apollo-router/src/plugins/progressive_override/mod.rs b/apollo-router/src/plugins/progressive_override/mod.rs index bcbf462afd..542b0d0722 100644 --- a/apollo-router/src/plugins/progressive_override/mod.rs +++ b/apollo-router/src/plugins/progressive_override/mod.rs @@ -29,7 +29,7 @@ pub(crate) const LABELS_TO_OVERRIDE_KEY: &str = "apollo_override::labels_to_over pub(crate) const JOIN_FIELD_DIRECTIVE_NAME: &str = "join__field"; pub(crate) const JOIN_SPEC_BASE_URL: &str = "https://specs.apollo.dev/join"; -pub(crate) const JOIN_SPEC_VERSION_RANGE: &str = ">=0.4.0, <=0.4.0"; +pub(crate) const JOIN_SPEC_VERSION_RANGE: &str = ">=0.4"; pub(crate) const OVERRIDE_LABEL_ARG_NAME: &str = "overrideLabel"; /// Configuration for the progressive override plugin diff --git a/apollo-router/src/plugins/progressive_override/tests.rs b/apollo-router/src/plugins/progressive_override/tests.rs index d8b3cb31af..0cead42fd9 100644 --- a/apollo-router/src/plugins/progressive_override/tests.rs +++ b/apollo-router/src/plugins/progressive_override/tests.rs @@ -1,5 +1,6 @@ use std::sync::Arc; +use apollo_compiler::Schema; use tower::ServiceExt; use crate::metrics::FutureMetricsExt; @@ -9,6 +10,9 @@ use crate::plugin::Plugin; use crate::plugin::PluginInit; use crate::plugins::progressive_override::Config; use crate::plugins::progressive_override::ProgressiveOverridePlugin; +use crate::plugins::progressive_override::JOIN_FIELD_DIRECTIVE_NAME; +use crate::plugins::progressive_override::JOIN_SPEC_BASE_URL; +use crate::plugins::progressive_override::JOIN_SPEC_VERSION_RANGE; use crate::plugins::progressive_override::LABELS_TO_OVERRIDE_KEY; use crate::plugins::progressive_override::UNRESOLVED_LABELS_KEY; use crate::services::layers::query_analysis::ParsedDocument; @@ -22,6 +26,49 @@ use crate::TestHarness; const SCHEMA: &str = include_str!("testdata/supergraph.graphql"); const SCHEMA_NO_USAGES: &str = include_str!("testdata/supergraph_no_usages.graphql"); +#[test] +fn test_progressive_overrides_are_recognised_vor_join_v0_4_and_above() { + let schema_for_version = |version| { + format!( + r#"schema + @link(url: "https://specs.apollo.dev/link/v1.0") + @link(url: "https://specs.apollo.dev/join/{}", for: EXECUTION) + @link(url: "https://specs.apollo.dev/context/v0.1", for: SECURITY) + + directive @join__field repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION"#, + version + ) + }; + + let join_v3_schema = Schema::parse(schema_for_version("v0.3"), "test").unwrap(); + assert!(crate::spec::Schema::directive_name( + &join_v3_schema, + JOIN_SPEC_BASE_URL, + JOIN_SPEC_VERSION_RANGE, + JOIN_FIELD_DIRECTIVE_NAME, + ) + .is_none()); + + let join_v4_schema = Schema::parse(schema_for_version("v0.4"), "test").unwrap(); + assert!(crate::spec::Schema::directive_name( + &join_v4_schema, + JOIN_SPEC_BASE_URL, + JOIN_SPEC_VERSION_RANGE, + JOIN_FIELD_DIRECTIVE_NAME, + ) + .is_some()); + + let join_v5_schema = Schema::parse(schema_for_version("v0.5"), "test").unwrap(); + + assert!(crate::spec::Schema::directive_name( + &join_v5_schema, + JOIN_SPEC_BASE_URL, + JOIN_SPEC_VERSION_RANGE, + JOIN_FIELD_DIRECTIVE_NAME, + ) + .is_some()) +} + #[tokio::test] async fn plugin_disables_itself_with_no_progressive_override_usages() { let plugin = ProgressiveOverridePlugin::new(PluginInit::fake_new(