diff --git a/src/core/blueprint/index.rs b/src/core/blueprint/index.rs index c32c4dd760..55b23ecdce 100644 --- a/src/core/blueprint/index.rs +++ b/src/core/blueprint/index.rs @@ -1,3 +1,5 @@ +use std::collections::HashSet; + use indexmap::IndexMap; use super::InputObjectTypeDefinition; @@ -38,6 +40,16 @@ impl Index { matches!(def, Some(Definition::Scalar(_))) || scalar::Scalar::is_predefined(type_name) } + pub fn get_interfaces(&self) -> HashSet { + self.map + .iter() + .filter_map(|(_, (def, _))| match def { + Definition::Interface(interface) => Some(interface.name.to_owned()), + _ => None, + }) + .collect() + } + pub fn type_is_enum(&self, type_name: &str) -> bool { let def = self.map.get(type_name).map(|(def, _)| def); diff --git a/src/core/jit/builder.rs b/src/core/jit/builder.rs index 520ff3b92b..6044b35b7b 100644 --- a/src/core/jit/builder.rs +++ b/src/core/jit/builder.rs @@ -1,4 +1,4 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::ops::Deref; use std::sync::Arc; @@ -11,7 +11,7 @@ use async_graphql_value::Value; use super::model::{Directive as JitDirective, *}; use super::BuildError; -use crate::core::blueprint::{Blueprint, Definition, Index, QueryField}; +use crate::core::blueprint::{Blueprint, Index, QueryField}; use crate::core::counter::{Count, Counter}; use crate::core::jit::model::OperationPlan; use crate::core::{scalar, Type}; @@ -66,7 +66,6 @@ impl Conditions { pub struct Builder<'a> { pub index: Arc, - pub interfaces: Arc>, pub arg_id: Counter, pub field_id: Counter, pub document: &'a ExecutableDocument, @@ -76,23 +75,12 @@ pub struct Builder<'a> { impl<'a> Builder<'a> { pub fn new(blueprint: &Blueprint, document: &'a ExecutableDocument) -> Self { let index = Arc::new(blueprint.index()); - let interfaces = Arc::new( - blueprint - .definitions - .iter() - .filter_map(|def| match def { - Definition::Interface(interface) => Some(interface.name.to_owned()), - _ => None, - }) - .collect(), - ); Self { document, index, arg_id: Counter::default(), field_id: Counter::default(), - interfaces, } } @@ -377,7 +365,7 @@ impl<'a> Builder<'a> { operation.ty, self.index.clone(), is_introspection_query, - Some(Arc::clone(&self.interfaces)), + Some(self.index.get_interfaces()), ); Ok(plan) } diff --git a/src/core/jit/model.rs b/src/core/jit/model.rs index 94b9bba1ce..00b4ed1db9 100644 --- a/src/core/jit/model.rs +++ b/src/core/jit/model.rs @@ -317,7 +317,7 @@ pub struct OperationPlan { pub min_cache_ttl: Option, pub selection: Vec>, pub before: Option, - pub interfaces: Option>>, + pub interfaces: Option>, } impl OperationPlan { @@ -355,7 +355,7 @@ impl OperationPlan { operation_type: OperationType, index: Arc, is_introspection_query: bool, - interfaces: Option>>, + interfaces: Option>, ) -> Self where Input: Clone,