mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
Unify get_underlying_type_name and get_base_type functions (#788)
### What This is a no-op refactor that involves unifying `get_base_type` and `get_underlying_type_name` functions, whose motives are the same. ### How Replace the name of erstwhile `get_base_type` fn with `get_underlying_type_name`. Remove the latter. Update the rest of the code to use the new function. V3_GIT_ORIGIN_REV_ID: 0b0d999670641ba265fde153af9b43b4d865e215
This commit is contained in:
parent
9e98ed2310
commit
5efbb09500
@ -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<ModelName>,
|
||||
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
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ pub(crate) fn build_input_field_presets_annotation(
|
||||
) -> Option<NamespaceAnnotation> {
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user