Skip to content

Commit

Permalink
Fix bug in selection set equality checking (#5457)
Browse files Browse the repository at this point in the history
This PR fixes a bug in selection set equality checking where it compares the schema and selection set's type when it shouldn't.

Note that we encountered this bug when discovering that condition exclusion wasn't working as expected. With this bugfix, computing how to jump to each subgraph should be much faster when there are many subgraphs.

Co-authored-by: Derek Kuc <dkuc@apollographql.com>
  • Loading branch information
2 people authored and lrlna committed Jun 17, 2024
1 parent d8fd93a commit e410322
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apollo-federation/src/operation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,21 @@ impl Operation {
/// - For the type, stores the schema and the position in that schema instead of just the
/// `NamedType`.
/// - Stores selections in a map so they can be normalized efficiently.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone)]
pub(crate) struct SelectionSet {
pub(crate) schema: ValidFederationSchema,
pub(crate) type_position: CompositeTypeDefinitionPosition,
pub(crate) selections: Arc<SelectionMap>,
}

impl PartialEq for SelectionSet {
fn eq(&self, other: &Self) -> bool {
self.selections == other.selections
}
}

impl Eq for SelectionSet {}

mod selection_map {
use std::borrow::Cow;
use std::iter::Map;
Expand Down

0 comments on commit e410322

Please sign in to comment.