diff --git a/v3/crates/metadata-resolve/src/helpers/ndc_validation.rs b/v3/crates/metadata-resolve/src/helpers/ndc_validation.rs index 35757d5dce0..a2911f07e25 100644 --- a/v3/crates/metadata-resolve/src/helpers/ndc_validation.rs +++ b/v3/crates/metadata-resolve/src/helpers/ndc_validation.rs @@ -13,9 +13,7 @@ use open_dds::{ }; use thiserror::Error; -use crate::types::subgraph::{ - Qualified, QualifiedBaseType, QualifiedTypeName, QualifiedTypeReference, -}; +use crate::types::subgraph::{Qualified, QualifiedTypeName, QualifiedTypeReference}; #[derive(Debug, Error)] pub enum NDCValidationError { @@ -158,14 +156,6 @@ pub enum NDCValidationError { InternalSerializationError { err: serde_json::Error }, } -// Get the underlying type name by resolving Array and Nullable container types -pub fn get_underlying_type_name(output_type: &QualifiedTypeReference) -> &QualifiedTypeName { - match &output_type.underlying_type { - QualifiedBaseType::List(output_type) => get_underlying_type_name(output_type), - QualifiedBaseType::Named(type_name) => type_name, - } -} - pub fn validate_ndc( model_name: &Qualified, model: &models::Model, @@ -375,7 +365,7 @@ pub fn validate_ndc_command( // Check if the result_type of function/procedure actually has a scalar type or an object type. // If it is an object type, then validate the type mapping. - match get_underlying_type_name(command_output_type) { + match command_output_type.get_underlying_type_name() { QualifiedTypeName::Inbuilt(_command_output_type) => { // TODO: Validate that the type of command.output_type is // same as the &command_source_ndc.result_type diff --git a/v3/crates/metadata-resolve/src/stages/boolean_expressions/object.rs b/v3/crates/metadata-resolve/src/stages/boolean_expressions/object.rs index 9151d35f5a0..00479d21ec2 100644 --- a/v3/crates/metadata-resolve/src/stages/boolean_expressions/object.rs +++ b/v3/crates/metadata-resolve/src/stages/boolean_expressions/object.rs @@ -1,7 +1,6 @@ use super::graphql; use super::helpers; pub use super::{BooleanExpressionComparableRelationship, ResolvedObjectBooleanExpressionType}; -use crate::helpers::ndc_validation::get_underlying_type_name; use crate::stages::{graphql_config, object_types, scalar_boolean_expressions, type_permissions}; use crate::types::error::{BooleanExpressionError, Error}; use crate::types::subgraph::mk_qualified_type_name; @@ -190,7 +189,7 @@ fn resolve_comparable_fields( )?; // get type of field - let field_type = get_underlying_type_name(&field.field_type); + let field_type = field.field_type.get_underlying_type_name(); // get type underlying boolean expression let boolean_expression_underlying_type = match &raw_boolean_expression_type.operand { diff --git a/v3/crates/metadata-resolve/src/types/subgraph.rs b/v3/crates/metadata-resolve/src/types/subgraph.rs index bf6b10f858b..bcd8eb6c979 100644 --- a/v3/crates/metadata-resolve/src/types/subgraph.rs +++ b/v3/crates/metadata-resolve/src/types/subgraph.rs @@ -64,10 +64,10 @@ impl QualifiedTypeReference { Ok(qualifier) } - /// Get the base type of the underlying type - pub fn get_base_type(&self) -> &QualifiedTypeName { + /// Get the underlying type name by resolving Array and Nullable container types + pub fn get_underlying_type_name(&self) -> &QualifiedTypeName { match &self.underlying_type { - QualifiedBaseType::List(list_type) => list_type.get_base_type(), + QualifiedBaseType::List(list_type) => list_type.get_underlying_type_name(), QualifiedBaseType::Named(type_name) => type_name, } } diff --git a/v3/crates/schema/src/types/input_type.rs b/v3/crates/schema/src/types/input_type.rs index 34230ce9755..4e5ca93b907 100644 --- a/v3/crates/schema/src/types/input_type.rs +++ b/v3/crates/schema/src/types/input_type.rs @@ -220,7 +220,7 @@ pub(crate) fn build_input_field_presets_annotation( ) -> Option { let mut annotation = None; // If the field type is a custom object type, build the field presets annotation - if let QualifiedTypeName::Custom(field_type_name) = field_type.get_base_type() { + if let QualifiedTypeName::Custom(field_type_name) = field_type.get_underlying_type_name() { if let Some(field_object_type_representation) = gds.metadata.object_types.get(field_type_name) {