Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ dependencies = [
"reqwest",
"rhai",
"rmp",
"rowan",
"rstack",
"rust-embed",
"rustls",
Expand Down
2 changes: 1 addition & 1 deletion apollo-federation/src/display_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub(crate) fn write_indented_lines<T>(

pub(crate) struct DisplaySlice<'a, T>(pub(crate) &'a [T]);

impl<'a, T: Display> Display for DisplaySlice<'a, T> {
impl<T: Display> Display for DisplaySlice<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[")?;
let mut iter = self.0.iter();
Expand Down
13 changes: 2 additions & 11 deletions apollo-federation/src/link/context_spec_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ pub(crate) struct ContextDirectiveArguments<'doc> {
#[derive(Clone)]
pub(crate) struct ContextSpecDefinition {
url: Url,
minimum_federation_version: Option<Version>,
}

impl ContextSpecDefinition {
pub(crate) fn new(version: Version, minimum_federation_version: Option<Version>) -> Self {
pub(crate) fn new(version: Version) -> Self {
Self {
url: Url {
identity: Identity::context_identity(),
version,
},
minimum_federation_version,
}
}

Expand All @@ -61,19 +59,12 @@ impl SpecDefinition for ContextSpecDefinition {
fn url(&self) -> &Url {
&self.url
}

fn minimum_federation_version(&self) -> Option<&Version> {
self.minimum_federation_version.as_ref()
}
}

lazy_static! {
pub(crate) static ref CONTEXT_VERSIONS: SpecDefinitions<ContextSpecDefinition> = {
let mut definitions = SpecDefinitions::new(Identity::context_identity());
definitions.add(ContextSpecDefinition::new(
Version { major: 0, minor: 1 },
Some(Version { major: 2, minor: 8 }),
));
definitions.add(ContextSpecDefinition::new(Version { major: 0, minor: 1 }));
definitions
};
}
13 changes: 2 additions & 11 deletions apollo-federation/src/link/cost_spec_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const LIST_SIZE_DIRECTIVE_REQUIRE_ONE_SLICING_ARGUMENT_ARGUMENT_NAME: Name =
#[derive(Clone)]
pub struct CostSpecDefinition {
url: Url,
minimum_federation_version: Option<Version>,
}

macro_rules! propagate_demand_control_directives {
Expand Down Expand Up @@ -109,13 +108,12 @@ macro_rules! propagate_demand_control_directives_to_position {
}

impl CostSpecDefinition {
pub(crate) fn new(version: Version, minimum_federation_version: Option<Version>) -> Self {
pub(crate) fn new(version: Version) -> Self {
Self {
url: Url {
identity: Identity::cost_identity(),
version,
},
minimum_federation_version,
}
}

Expand Down Expand Up @@ -242,19 +240,12 @@ impl SpecDefinition for CostSpecDefinition {
fn url(&self) -> &Url {
&self.url
}

fn minimum_federation_version(&self) -> Option<&Version> {
self.minimum_federation_version.as_ref()
}
}

lazy_static! {
pub(crate) static ref COST_VERSIONS: SpecDefinitions<CostSpecDefinition> = {
let mut definitions = SpecDefinitions::new(Identity::cost_identity());
definitions.add(CostSpecDefinition::new(
Version { major: 0, minor: 1 },
Some(Version { major: 2, minor: 9 }),
));
definitions.add(CostSpecDefinition::new(Version { major: 0, minor: 1 }));
definitions
};
}
Expand Down
4 changes: 0 additions & 4 deletions apollo-federation/src/link/federation_spec_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,6 @@ impl SpecDefinition for FederationSpecDefinition {
fn url(&self) -> &Url {
&self.url
}

fn minimum_federation_version(&self) -> Option<&Version> {
None
}
}

lazy_static! {
Expand Down
24 changes: 9 additions & 15 deletions apollo-federation/src/link/inaccessible_spec_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ pub(crate) const INACCESSIBLE_DIRECTIVE_NAME_IN_SPEC: Name = name!("inaccessible

pub(crate) struct InaccessibleSpecDefinition {
url: Url,
minimum_federation_version: Option<Version>,
}

impl InaccessibleSpecDefinition {
pub(crate) fn new(version: Version, minimum_federation_version: Option<Version>) -> Self {
pub(crate) fn new(version: Version) -> Self {
Self {
url: Url {
identity: Identity::inaccessible_identity(),
version,
},
minimum_federation_version,
}
}

Expand Down Expand Up @@ -97,23 +95,19 @@ impl SpecDefinition for InaccessibleSpecDefinition {
fn url(&self) -> &Url {
&self.url
}

fn minimum_federation_version(&self) -> Option<&Version> {
self.minimum_federation_version.as_ref()
}
}

lazy_static! {
pub(crate) static ref INACCESSIBLE_VERSIONS: SpecDefinitions<InaccessibleSpecDefinition> = {
let mut definitions = SpecDefinitions::new(Identity::inaccessible_identity());
definitions.add(InaccessibleSpecDefinition::new(
Version { major: 0, minor: 1 },
None,
));
definitions.add(InaccessibleSpecDefinition::new(
Version { major: 0, minor: 2 },
Some(Version { major: 2, minor: 0 }),
));
definitions.add(InaccessibleSpecDefinition::new(Version {
major: 0,
minor: 1,
}));
definitions.add(InaccessibleSpecDefinition::new(Version {
major: 0,
minor: 2,
}));
definitions
};
}
Expand Down
33 changes: 6 additions & 27 deletions apollo-federation/src/link/join_spec_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,15 @@ pub(crate) struct EnumValueDirectiveArguments {
#[derive(Clone)]
pub(crate) struct JoinSpecDefinition {
url: Url,
minimum_federation_version: Option<Version>,
}

impl JoinSpecDefinition {
pub(crate) fn new(version: Version, minimum_federation_version: Option<Version>) -> Self {
pub(crate) fn new(version: Version) -> Self {
Self {
url: Url {
identity: Identity::join_identity(),
version,
},
minimum_federation_version,
}
}

Expand Down Expand Up @@ -410,35 +408,16 @@ impl SpecDefinition for JoinSpecDefinition {
fn url(&self) -> &Url {
&self.url
}

fn minimum_federation_version(&self) -> Option<&Version> {
self.minimum_federation_version.as_ref()
}
}

lazy_static! {
pub(crate) static ref JOIN_VERSIONS: SpecDefinitions<JoinSpecDefinition> = {
let mut definitions = SpecDefinitions::new(Identity::join_identity());
definitions.add(JoinSpecDefinition::new(
Version { major: 0, minor: 1 },
None,
));
definitions.add(JoinSpecDefinition::new(
Version { major: 0, minor: 2 },
None,
));
definitions.add(JoinSpecDefinition::new(
Version { major: 0, minor: 3 },
Some(Version { major: 2, minor: 0 }),
));
definitions.add(JoinSpecDefinition::new(
Version { major: 0, minor: 4 },
Some(Version { major: 2, minor: 7 }),
));
definitions.add(JoinSpecDefinition::new(
Version { major: 0, minor: 5 },
Some(Version { major: 2, minor: 8 }),
));
definitions.add(JoinSpecDefinition::new(Version { major: 0, minor: 1 }));
definitions.add(JoinSpecDefinition::new(Version { major: 0, minor: 2 }));
definitions.add(JoinSpecDefinition::new(Version { major: 0, minor: 3 }));
definitions.add(JoinSpecDefinition::new(Version { major: 0, minor: 4 }));
definitions.add(JoinSpecDefinition::new(Version { major: 0, minor: 5 }));
definitions
};
}
15 changes: 1 addition & 14 deletions apollo-federation/src/link/link_spec_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@ use crate::link::spec_definition::SpecDefinitions;

pub(crate) struct LinkSpecDefinition {
url: Url,
minimum_federation_version: Option<Version>,
}

impl LinkSpecDefinition {
pub(crate) fn new(
version: Version,
minimum_federation_version: Option<Version>,
identity: Identity,
) -> Self {
pub(crate) fn new(version: Version, identity: Identity) -> Self {
Self {
url: Url { identity, version },
minimum_federation_version,
}
}
}
Expand All @@ -28,23 +22,17 @@ impl SpecDefinition for LinkSpecDefinition {
fn url(&self) -> &Url {
&self.url
}

fn minimum_federation_version(&self) -> Option<&Version> {
self.minimum_federation_version.as_ref()
}
}

lazy_static! {
pub(crate) static ref CORE_VERSIONS: SpecDefinitions<LinkSpecDefinition> = {
let mut definitions = SpecDefinitions::new(Identity::core_identity());
definitions.add(LinkSpecDefinition::new(
Version { major: 0, minor: 1 },
None,
Identity::core_identity(),
));
definitions.add(LinkSpecDefinition::new(
Version { major: 0, minor: 2 },
Some(Version { major: 2, minor: 0 }),
Identity::core_identity(),
));
definitions
Expand All @@ -53,7 +41,6 @@ lazy_static! {
let mut definitions = SpecDefinitions::new(Identity::link_identity());
definitions.add(LinkSpecDefinition::new(
Version { major: 1, minor: 0 },
Some(Version { major: 2, minor: 0 }),
Identity::link_identity(),
));
definitions
Expand Down
6 changes: 3 additions & 3 deletions apollo-federation/src/link/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct DisplayName<'s> {
is_directive: bool,
}

impl<'s> fmt::Display for DisplayName<'s> {
impl fmt::Display for DisplayName<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_directive {
f.write_str("@")?;
Expand Down Expand Up @@ -440,11 +440,11 @@ impl LinksMetadata {
}

pub fn all_links(&self) -> &[Arc<Link>] {
return self.links.as_ref();
self.links.as_ref()
}

pub fn for_identity(&self, identity: &Identity) -> Option<Arc<Link>> {
return self.by_identity.get(identity).cloned();
self.by_identity.get(identity).cloned()
}

pub fn source_link_of_type(&self, type_name: &Name) -> Option<LinkedElement> {
Expand Down
18 changes: 0 additions & 18 deletions apollo-federation/src/link/spec_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use crate::schema::FederationSchema;

pub(crate) trait SpecDefinition {
fn url(&self) -> &Url;
fn minimum_federation_version(&self) -> Option<&Version>;

fn identity(&self) -> &Identity {
&self.url().identity
Expand All @@ -27,23 +26,6 @@ pub(crate) trait SpecDefinition {
&self.url().version
}

fn is_spec_directive_name(
&self,
schema: &FederationSchema,
name_in_schema: &Name,
) -> Result<bool, FederationError> {
let Some(metadata) = schema.metadata() else {
return Err(SingleFederationError::Internal {
message: "Schema is not a core schema (add @link first)".to_owned(),
}
.into());
};
Ok(metadata
.source_link_of_directive(name_in_schema)
.map(|e| e.link.url.identity == *self.identity())
.unwrap_or(false))
}

fn is_spec_type_name(
&self,
schema: &FederationSchema,
Expand Down
6 changes: 3 additions & 3 deletions apollo-federation/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl From<FederationError> for MergeFailure {
}

pub struct MergeFailure {
pub schema: Option<Schema>,
pub schema: Option<Box<Schema>>,
pub errors: Vec<MergeError>,
pub composition_hints: Vec<MergeWarning>,
}
Expand Down Expand Up @@ -252,7 +252,7 @@ impl Merger {
})
} else {
Err(MergeFailure {
schema: Some(supergraph),
schema: Some(Box::new(supergraph)),
composition_hints: self.composition_hints.to_owned(),
errors: self.errors.to_owned(),
})
Expand Down Expand Up @@ -1535,7 +1535,7 @@ fn join_graph_enum_type(

fn add_core_feature_inaccessible(supergraph: &mut Schema) {
// @link(url: "https://specs.apollo.dev/inaccessible/v0.2")
let spec = InaccessibleSpecDefinition::new(Version { major: 0, minor: 2 }, None);
let spec = InaccessibleSpecDefinition::new(Version { major: 0, minor: 2 });

supergraph
.schema_definition
Expand Down
4 changes: 1 addition & 3 deletions apollo-federation/src/operation/directive_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ impl DirectiveList {
// Nothing to do on an empty list
return None;
};
let Some(index) = inner.directives.iter().position(|dir| dir.name == name) else {
return None;
};
let index = inner.directives.iter().position(|dir| dir.name == name)?;

// The directive exists and is the only directive: switch to the empty representation
if inner.len() == 1 {
Expand Down
6 changes: 3 additions & 3 deletions apollo-federation/src/operation/merging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::ensure;
use crate::error::FederationError;
use crate::error::SingleFederationError;

impl<'a> FieldSelectionValue<'a> {
impl FieldSelectionValue<'_> {
/// Merges the given field selections into this one.
///
/// # Preconditions
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<'a> FieldSelectionValue<'a> {
}
}

impl<'a> InlineFragmentSelectionValue<'a> {
impl InlineFragmentSelectionValue<'_> {
/// Merges the given normalized inline fragment selections into this one.
///
/// # Preconditions
Expand Down Expand Up @@ -117,7 +117,7 @@ impl<'a> InlineFragmentSelectionValue<'a> {
}
}

impl<'a> FragmentSpreadSelectionValue<'a> {
impl FragmentSpreadSelectionValue<'_> {
/// Merges the given normalized fragment spread selections into this one.
///
/// # Preconditions
Expand Down
Loading