Rename boolean_expression_type to object_boolean_expression_type (#567)

<!-- Thank you for submitting this PR! :) -->

## Description

There is about to be a separate thing called `boolean_expression_type`,
so let's have a nice time and make the two things explicitly different.

Functional no-op.

V3_GIT_ORIGIN_REV_ID: 0035e39a2ca8657a6ded5d5f0a4f284c3e72126d
This commit is contained in:
Daniel Harvey 2024-05-10 13:26:27 +01:00 committed by hasura-bot
parent 42b1a63484
commit 0e2eb62874
16 changed files with 125 additions and 117 deletions

View File

@ -71,7 +71,7 @@ pub fn get_argument_mappings<'a>(
type_permissions::ObjectTypeWithPermissions,
>,
scalar_types: &'a HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &'a HashMap<
object_boolean_expression_types: &'a HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -128,7 +128,7 @@ pub fn get_argument_mappings<'a>(
object_type_name,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
)
.map_err(|_| ArgumentMappingError::UnknownType {
argument_name: argument_name.clone(),
@ -147,14 +147,14 @@ pub fn get_argument_mappings<'a>(
})
}
TypeRepresentation::Scalar(_) => (),
TypeRepresentation::BooleanExpression(boolean_expression_type) => {
TypeRepresentation::BooleanExpression(object_boolean_expression_type) => {
let underlying_ndc_argument_named_type =
ndc_validation::get_underlying_named_type(&ndc_argument_info.argument_type)
.map_err(ArgumentMappingError::NDCValidationError)?;
// resolve the object type the boolean expression refers to
type_mappings_to_collect.push(type_mappings::TypeMappingToCollect {
type_name: &boolean_expression_type.object_type,
type_name: &object_boolean_expression_type.object_type,
ndc_object_type_name: DataConnectorObjectType::ref_cast(
underlying_ndc_argument_named_type,
),
@ -189,7 +189,7 @@ pub(crate) fn resolve_value_expression_for_argument(
subgraph: &str,
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -215,24 +215,25 @@ pub(crate) fn resolve_value_expression_for_argument(
})?;
// lookup the relevant ObjectBooleanExpressionType
let boolean_expression_type =
boolean_expression_types
.get(base_type)
.ok_or_else(|| Error::UnknownType {
data_type: base_type.clone(),
})?;
let object_boolean_expression_type = object_boolean_expression_types
.get(base_type)
.ok_or_else(|| Error::UnknownType {
data_type: base_type.clone(),
})?;
// get the type that the expression is based on
let object_type_representation =
get_object_type_for_boolean_expression(boolean_expression_type, object_types)?;
let object_type_representation = get_object_type_for_boolean_expression(
object_boolean_expression_type,
object_types,
)?;
// look up this type in the context of it's data connector
// so that we use the correct column names for the data source
let data_connector_field_mappings = object_type_representation
.type_mappings
.get(
&boolean_expression_type.data_connector_name,
&boolean_expression_type.data_connector_object_type,
&object_boolean_expression_type.data_connector_name,
&object_boolean_expression_type.data_connector_object_type,
)
.map(|type_mapping| match type_mapping {
object_types::TypeMapping::Object { field_mappings, .. } => field_mappings,
@ -241,8 +242,10 @@ pub(crate) fn resolve_value_expression_for_argument(
type_name: base_type.clone(),
error: TypeMappingValidationError::DataConnectorTypeMappingNotFound {
object_type_name: base_type.clone(),
data_connector_name: boolean_expression_type.data_connector_name.clone(),
data_connector_object_type: boolean_expression_type
data_connector_name: object_boolean_expression_type
.data_connector_name
.clone(),
data_connector_object_type: object_boolean_expression_type
.data_connector_object_type
.clone(),
},
@ -253,7 +256,7 @@ pub(crate) fn resolve_value_expression_for_argument(
base_type,
object_type_representation,
data_connector_field_mappings,
&boolean_expression_type.data_connector_name,
&object_boolean_expression_type.data_connector_name,
subgraph,
data_connectors,
object_types,

View File

@ -44,12 +44,12 @@ pub enum TypeRepresentation<'a, ObjectType> {
}
/// validate whether a given CustomTypeName exists within `object_types`, `scalar_types` or
/// `boolean_expression_types`
/// `object_boolean_expression_types`
pub fn get_type_representation<'a, ObjectType>(
custom_type_name: &Qualified<CustomTypeName>,
object_types: &'a HashMap<Qualified<CustomTypeName>, ObjectType>,
scalar_types: &'a HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &'a HashMap<
object_boolean_expression_types: &'a HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -62,9 +62,9 @@ pub fn get_type_representation<'a, ObjectType>(
Some(scalar_type_representation) => {
Ok(TypeRepresentation::Scalar(scalar_type_representation))
}
None => match boolean_expression_types.get(custom_type_name) {
Some(boolean_expression_type) => Ok(TypeRepresentation::BooleanExpression(
boolean_expression_type,
None => match object_boolean_expression_types.get(custom_type_name) {
Some(object_boolean_expression_type) => Ok(TypeRepresentation::BooleanExpression(
object_boolean_expression_type,
)),
None => Err(Error::UnknownType {
data_type: custom_type_name.clone(),
@ -75,17 +75,17 @@ pub fn get_type_representation<'a, ObjectType>(
}
pub(crate) fn get_object_type_for_boolean_expression<'a>(
boolean_expression_type: &boolean_expressions::ObjectBooleanExpressionType,
object_boolean_expression_type: &boolean_expressions::ObjectBooleanExpressionType,
object_types: &'a HashMap<
Qualified<CustomTypeName>,
relationships::ObjectTypeWithRelationships,
>,
) -> Result<&'a relationships::ObjectTypeWithRelationships, Error> {
object_types
.get(&boolean_expression_type.object_type)
.get(&object_boolean_expression_type.object_type)
.ok_or(Error::from(
BooleanExpressionError::UnsupportedTypeInObjectBooleanExpressionType {
type_name: boolean_expression_type.object_type.clone(),
type_name: object_boolean_expression_type.object_type.clone(),
},
))
}

View File

@ -27,16 +27,16 @@ pub fn resolve(
existing_graphql_types: &HashSet<ast::TypeName>,
graphql_config: &graphql_config::GraphqlConfig,
) -> Result<BooleanExpressionsOutput, Error> {
let mut boolean_expression_types = HashMap::new();
let mut object_boolean_expression_types = HashMap::new();
let mut graphql_types = existing_graphql_types.clone();
for open_dds::accessor::QualifiedObject {
subgraph,
object: boolean_expression_type,
} in &metadata_accessor.boolean_expression_types
object: object_boolean_expression_type,
} in &metadata_accessor.object_boolean_expression_types
{
let resolved_boolean_expression = resolve_boolean_expression_type(
boolean_expression_type,
let resolved_boolean_expression = resolve_object_boolean_expression_type(
object_boolean_expression_type,
subgraph,
data_connectors,
object_types,
@ -44,7 +44,7 @@ pub fn resolve(
&mut graphql_types,
graphql_config,
)?;
if let Some(existing) = boolean_expression_types.insert(
if let Some(existing) = object_boolean_expression_types.insert(
resolved_boolean_expression.name.clone(),
resolved_boolean_expression,
) {
@ -56,13 +56,13 @@ pub fn resolve(
}
}
Ok(BooleanExpressionsOutput {
boolean_expression_types,
object_boolean_expression_types,
graphql_types,
})
}
/// Resolves a given object boolean expression type
pub(crate) fn resolve_boolean_expression_type(
pub(crate) fn resolve_object_boolean_expression_type(
object_boolean_expression: &open_dds::types::ObjectBooleanExpressionTypeV1,
subgraph: &str,
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
@ -105,7 +105,7 @@ pub(crate) fn resolve_boolean_expression_type(
Error::from(
BooleanExpressionError::UnknownDataConnectorInObjectBooleanExpressionType {
data_connector: qualified_data_connector_name.clone(),
boolean_expression_type: qualified_name.clone(),
object_boolean_expression_type: qualified_name.clone(),
},
)
})?;
@ -120,7 +120,7 @@ pub(crate) fn resolve_boolean_expression_type(
return Err(Error::from(
BooleanExpressionError::UnknownDataConnectorTypeInObjectBooleanExpressionType {
data_connector: qualified_data_connector_name.clone(),
boolean_expression_type: qualified_name.clone(),
object_boolean_expression_type: qualified_name.clone(),
data_connector_object_type: object_boolean_expression
.data_connector_object_type
.clone(),
@ -136,7 +136,7 @@ pub(crate) fn resolve_boolean_expression_type(
.ok_or_else(|| {
Error::from(BooleanExpressionError::NoDataConnectorTypeMappingForObjectTypeInBooleanExpression {
object_type: qualified_object_type_name.clone(),
boolean_expression_type: qualified_name.clone(),
object_boolean_expression_type: qualified_name.clone(),
data_connector_object_type: object_boolean_expression
.data_connector_object_type.clone(),
data_connector: qualified_data_connector_name.clone(),
@ -153,7 +153,7 @@ pub(crate) fn resolve_boolean_expression_type(
return Err(
BooleanExpressionError::UnknownFieldInObjectBooleanExpressionType {
field_name: comparable_field.field_name.clone(),
boolean_expression_type: qualified_name.clone(),
object_boolean_expression_type: qualified_name.clone(),
}
.into(),
);
@ -179,7 +179,7 @@ pub(crate) fn resolve_boolean_expression_type(
});
}
let boolean_expression_type =
let object_boolean_expression_type =
Qualified::new(subgraph.to_string(), object_boolean_expression.name.clone());
let object_type = Qualified::new(
@ -209,7 +209,7 @@ pub(crate) fn resolve_boolean_expression_type(
.map_err(|error| {
Error::from(
BooleanExpressionError::BooleanExpressionTypeMappingCollectionError {
boolean_expression_type: boolean_expression_type.clone(),
object_boolean_expression_type: object_boolean_expression_type.clone(),
error,
},
)
@ -233,7 +233,7 @@ pub(crate) fn resolve_boolean_expression_type(
.unwrap();
resolve_boolean_expression_info(
&boolean_expression_type,
&object_boolean_expression_type,
&data_connector_name,
graphql_type_name.clone(),
subgraph,
@ -280,7 +280,7 @@ pub fn resolve_boolean_expression_info(
.ok_or(Error::BooleanExpressionError {
boolean_expression_error:
BooleanExpressionError::UnknownDataConnectorInObjectBooleanExpressionType {
boolean_expression_type: name.clone(),
object_boolean_expression_type: name.clone(),
data_connector: data_connector_name.clone(),
},
})?

View File

@ -14,7 +14,8 @@ use open_dds::{
use serde::{Deserialize, Serialize};
pub struct BooleanExpressionsOutput {
pub boolean_expression_types: HashMap<Qualified<CustomTypeName>, ObjectBooleanExpressionType>,
pub object_boolean_expression_types:
HashMap<Qualified<CustomTypeName>, ObjectBooleanExpressionType>,
pub graphql_types: HashSet<ast::TypeName>,
}

View File

@ -40,7 +40,7 @@ pub fn resolve(
commands: &IndexMap<Qualified<CommandName>, commands::Command>,
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -78,7 +78,7 @@ pub fn resolve(
command_permissions,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
models,
data_connectors,
subgraph,
@ -97,7 +97,7 @@ pub fn resolve_command_permissions(
permissions: &CommandPermissionsV1,
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -126,7 +126,7 @@ pub fn resolve_command_permissions(
subgraph,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
models,
data_connectors,
)?;

View File

@ -30,7 +30,7 @@ pub fn resolve(
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -46,7 +46,7 @@ pub fn resolve(
subgraph,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
)?;
if let Some(command_source) = &command.source {
resolve_command_source(
@ -56,7 +56,7 @@ pub fn resolve(
data_connectors,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
)?;
}
let qualified_command_name = Qualified::new(subgraph.to_string(), command.name.clone());
@ -77,7 +77,7 @@ fn type_exists(
subgraph: &str,
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -88,7 +88,7 @@ fn type_exists(
subgraph,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
),
BaseType::Named(type_name) => match type_name {
TypeName::Inbuilt(_) => true,
@ -100,7 +100,7 @@ fn type_exists(
&qualified_type_name,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
)
.is_ok()
}
@ -113,7 +113,7 @@ pub fn resolve_command(
subgraph: &str,
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -128,7 +128,7 @@ pub fn resolve_command(
subgraph,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
) {
if arguments
.insert(
@ -187,7 +187,7 @@ pub fn resolve_command_source(
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -254,7 +254,7 @@ pub fn resolve_command_source(
ndc_arguments,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
)
.map_err(|err| match &command_source.data_connector_command {
DataConnectorCommand::Function(function_name) => {

View File

@ -57,7 +57,7 @@ pub fn resolve(metadata: open_dds::Metadata) -> Result<Metadata, Error> {
type_permissions::resolve(&metadata_accessor, &object_types)?;
let boolean_expressions::BooleanExpressionsOutput {
boolean_expression_types,
object_boolean_expression_types,
graphql_types,
} = boolean_expressions::resolve(
&metadata_accessor,
@ -81,7 +81,7 @@ pub fn resolve(metadata: open_dds::Metadata) -> Result<Metadata, Error> {
&apollo_federation_entity_enabled_types,
&object_types_with_permissions,
&scalar_types,
&boolean_expression_types,
&object_boolean_expression_types,
&graphql_config,
)?;
@ -90,7 +90,7 @@ pub fn resolve(metadata: open_dds::Metadata) -> Result<Metadata, Error> {
&data_connectors,
&object_types_with_permissions,
&scalar_types,
&boolean_expression_types,
&object_boolean_expression_types,
)?;
apollo::resolve(
@ -111,7 +111,7 @@ pub fn resolve(metadata: open_dds::Metadata) -> Result<Metadata, Error> {
&commands,
&object_types_with_relationships,
&scalar_types,
&boolean_expression_types,
&object_boolean_expression_types,
&models,
&data_connectors,
)?;
@ -122,7 +122,7 @@ pub fn resolve(metadata: open_dds::Metadata) -> Result<Metadata, Error> {
&object_types_with_relationships,
&scalar_types,
&models,
&boolean_expression_types,
&object_boolean_expression_types,
)?;
let roles = roles::resolve(
@ -136,7 +136,7 @@ pub fn resolve(metadata: open_dds::Metadata) -> Result<Metadata, Error> {
object_types: object_types_with_relationships,
models: models_with_permissions,
commands: commands_with_permissions,
boolean_expression_types,
object_boolean_expression_types,
graphql_config: graphql_config.global,
roles,
})

View File

@ -36,7 +36,7 @@ pub fn resolve(
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
models: &IndexMap<Qualified<ModelName>, models::Model>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -78,7 +78,7 @@ pub fn resolve(
object_types,
scalar_types,
models, // This is required to get the model for the relationship target
boolean_expression_types,
object_boolean_expression_types,
)?;
model.select_permissions = select_permissions;
@ -503,7 +503,7 @@ pub fn resolve_model_select_permissions(
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
models: &IndexMap<Qualified<ModelName>, models::Model>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -544,7 +544,7 @@ pub fn resolve_model_select_permissions(
subgraph,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
models,
data_connectors,
)?;

View File

@ -46,7 +46,7 @@ pub fn resolve(
>,
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -71,7 +71,7 @@ pub fn resolve(
object_types,
&mut global_id_enabled_types,
&mut apollo_federation_entity_enabled_types,
boolean_expression_types,
object_boolean_expression_types,
)?;
if resolved_model.global_id_source.is_some() {
match global_id_models.insert(
@ -97,7 +97,7 @@ pub fn resolve(
data_connectors,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
)?;
}
if let Some(model_graphql_definition) = &model.graphql {
@ -132,7 +132,7 @@ fn resolve_filter_expression_type(
model: &ModelV1,
model_data_type: &Qualified<CustomTypeName>,
subgraph: &str,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -141,23 +141,25 @@ fn resolve_filter_expression_type(
.filter_expression_type
.as_ref()
.map(|filter_expression_type| {
let boolean_expression_type_name =
let object_boolean_expression_type_name =
Qualified::new(subgraph.to_string(), filter_expression_type.clone());
let boolean_expression_type = boolean_expression_types
.get(&boolean_expression_type_name)
let object_boolean_expression_type = object_boolean_expression_types
.get(&object_boolean_expression_type_name)
.ok_or_else(|| {
Error::from(
BooleanExpressionError::UnknownBooleanExpressionTypeInModel {
name: boolean_expression_type_name.clone(),
name: object_boolean_expression_type_name.clone(),
model: Qualified::new(subgraph.to_string(), model.name.clone()),
},
)
})?;
if boolean_expression_type.object_type != *model_data_type {
if object_boolean_expression_type.object_type != *model_data_type {
return Err(Error::from(
BooleanExpressionError::BooleanExpressionTypeForInvalidObjectTypeInModel {
name: boolean_expression_type_name.clone(),
boolean_expression_object_type: boolean_expression_type.object_type.clone(),
name: object_boolean_expression_type_name.clone(),
boolean_expression_object_type: object_boolean_expression_type
.object_type
.clone(),
model: Qualified::new(subgraph.to_string(), model.name.clone()),
model_object_type: model_data_type.clone(),
},
@ -172,7 +174,7 @@ fn resolve_filter_expression_type(
// TODO: Compatibility of model source and the boolean expression type is checked in
// resolve_model_source. Figure out a way to make this logic not scattered.
}
Ok(boolean_expression_type.clone())
Ok(object_boolean_expression_type.clone())
})
.transpose()
}
@ -217,7 +219,7 @@ fn resolve_model(
Qualified<CustomTypeName>,
Option<Qualified<ModelName>>,
>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -340,7 +342,7 @@ fn resolve_model(
model,
&qualified_object_type_name,
subgraph,
boolean_expression_types,
object_boolean_expression_types,
)?;
Ok(Model {
@ -570,7 +572,7 @@ fn resolve_model_source(
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
boolean_expression_types: &HashMap<
object_boolean_expression_types: &HashMap<
Qualified<CustomTypeName>,
boolean_expressions::ObjectBooleanExpressionType,
>,
@ -611,7 +613,7 @@ fn resolve_model_source(
&source_collection.arguments,
object_types,
scalar_types,
boolean_expression_types,
object_boolean_expression_types,
)
.map_err(|err| Error::ModelCollectionArgumentMappingError {
data_connector_name: qualified_data_connector_name.clone(),

View File

@ -21,7 +21,7 @@ pub struct Metadata {
pub scalar_types: HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
pub models: IndexMap<Qualified<ModelName>, model_permissions::ModelWithPermissions>,
pub commands: IndexMap<Qualified<CommandName>, command_permissions::CommandWithPermissions>,
pub boolean_expression_types:
pub object_boolean_expression_types:
HashMap<Qualified<CustomTypeName>, boolean_expressions::ObjectBooleanExpressionType>,
pub graphql_config: graphql_config::GlobalGraphqlConfig,
pub roles: Vec<Role>,

View File

@ -597,32 +597,32 @@ pub enum BooleanExpressionError {
UnsupportedTypeInObjectBooleanExpressionType {
type_name: Qualified<CustomTypeName>,
},
#[error("unknown data connector {data_connector:} referenced in object boolean expression type {boolean_expression_type:}")]
#[error("unknown data connector {data_connector:} referenced in object boolean expression type {object_boolean_expression_type:}")]
UnknownDataConnectorInObjectBooleanExpressionType {
data_connector: Qualified<DataConnectorName>,
boolean_expression_type: Qualified<CustomTypeName>,
object_boolean_expression_type: Qualified<CustomTypeName>,
},
#[error("unknown data connector object type {data_connector_object_type:} (in data connector {data_connector:}) referenced in object boolean expression type {boolean_expression_type:}")]
#[error("unknown data connector object type {data_connector_object_type:} (in data connector {data_connector:}) referenced in object boolean expression type {object_boolean_expression_type:}")]
UnknownDataConnectorTypeInObjectBooleanExpressionType {
data_connector: Qualified<DataConnectorName>,
data_connector_object_type: DataConnectorObjectType,
boolean_expression_type: Qualified<CustomTypeName>,
object_boolean_expression_type: Qualified<CustomTypeName>,
},
#[error("unknown field '{field_name:}' used in object boolean expression type {boolean_expression_type:}")]
#[error("unknown field '{field_name:}' used in object boolean expression type {object_boolean_expression_type:}")]
UnknownFieldInObjectBooleanExpressionType {
field_name: FieldName,
boolean_expression_type: Qualified<CustomTypeName>,
object_boolean_expression_type: Qualified<CustomTypeName>,
},
#[error("the object type '{object_type:}' used in boolean expression type {boolean_expression_type:} does not have a mapping to object {data_connector_object_type:} of data connector {data_connector:}")]
#[error("the object type '{object_type:}' used in boolean expression type {object_boolean_expression_type:} does not have a mapping to object {data_connector_object_type:} of data connector {data_connector:}")]
NoDataConnectorTypeMappingForObjectTypeInBooleanExpression {
object_type: Qualified<CustomTypeName>,
boolean_expression_type: Qualified<CustomTypeName>,
object_boolean_expression_type: Qualified<CustomTypeName>,
data_connector_object_type: DataConnectorObjectType,
data_connector: Qualified<DataConnectorName>,
},
#[error("{error:} in boolean expression type {boolean_expression_type:}")]
#[error("{error:} in boolean expression type {object_boolean_expression_type:}")]
BooleanExpressionTypeMappingCollectionError {
boolean_expression_type: Qualified<CustomTypeName>,
object_boolean_expression_type: Qualified<CustomTypeName>,
error: TypeMappingCollectionError,
},
#[error("the following object boolean expression type is defined more than once: {name:}")]

View File

@ -26,7 +26,7 @@ lazy_static::lazy_static! {
pub struct MetadataAccessor {
pub data_connectors: Vec<QualifiedObject<data_connector::DataConnectorLinkV1>>,
pub object_types: Vec<QualifiedObject<types::ObjectTypeV1>>,
pub boolean_expression_types: Vec<QualifiedObject<types::ObjectBooleanExpressionTypeV1>>,
pub object_boolean_expression_types: Vec<QualifiedObject<types::ObjectBooleanExpressionTypeV1>>,
pub scalar_types: Vec<QualifiedObject<types::ScalarTypeV1>>,
pub data_connector_scalar_representations:
Vec<QualifiedObject<types::DataConnectorScalarRepresentationV1>>,
@ -63,11 +63,13 @@ fn load_metadata_objects(
.scalar_types
.push(QualifiedObject::new(subgraph, scalar_type.upgrade()));
}
OpenDdSubgraphObject::ObjectBooleanExpressionType(boolean_expression_type) => {
accessor.boolean_expression_types.push(QualifiedObject::new(
subgraph,
boolean_expression_type.upgrade(),
));
OpenDdSubgraphObject::ObjectBooleanExpressionType(object_boolean_expression_type) => {
accessor
.object_boolean_expression_types
.push(QualifiedObject::new(
subgraph,
object_boolean_expression_type.upgrade(),
));
}
OpenDdSubgraphObject::DataConnectorScalarRepresentation(scalar_representation) => {
accessor
@ -158,7 +160,7 @@ impl MetadataAccessor {
data_connectors: vec![],
object_types: vec![],
scalar_types: vec![],
boolean_expression_types: vec![],
object_boolean_expression_types: vec![],
data_connector_scalar_representations: vec![],
models: vec![],
type_permissions: vec![],

View File

@ -22,15 +22,15 @@ pub fn build_boolean_expression_input_schema(
type_name: &ast::TypeName,
gds_type_name: &Qualified<CustomTypeName>,
) -> Result<gql_schema::TypeInfo<GDS>, Error> {
let boolean_expression_type = gds
let object_boolean_expression_type = gds
.metadata
.boolean_expression_types
.object_boolean_expression_types
.get(gds_type_name)
.ok_or_else(|| Error::InternalTypeNotFound {
type_name: gds_type_name.clone(),
})?;
if let Some(boolean_expression_info) = &boolean_expression_type.graphql {
if let Some(boolean_expression_info) = &object_boolean_expression_type.graphql {
let mut input_fields = BTreeMap::new();
// `_and`, `_or` or `_not` fields are available for all roles
@ -103,7 +103,7 @@ pub fn build_boolean_expression_input_schema(
);
let object_type_representation =
get_object_type_representation(gds, &boolean_expression_type.object_type)?;
get_object_type_representation(gds, &object_boolean_expression_type.object_type)?;
// column fields
for (field_name, comparison_expression) in &boolean_expression_info.scalar_fields {
@ -168,20 +168,20 @@ pub fn build_boolean_expression_input_schema(
// filter expression with relationships is currently only supported for local relationships
if let metadata_resolve::RelationshipExecutionCategory::Local =
metadata_resolve::relationship_execution_category(
&boolean_expression_type.data_connector_link,
&object_boolean_expression_type.data_connector_link,
&target_source.data_connector,
&target_model_source.capabilities,
)
{
if target_source.data_connector.name
== boolean_expression_type.data_connector_name
== object_boolean_expression_type.data_connector_name
{
// If the relationship target model does not have filterExpressionType do not include
// it in the source model filter expression input type.
if let Some(ref target_model_filter_expression) =
&target_model.model.clone().filter_expression_type.and_then(
|ref boolean_expression_type| {
boolean_expression_type.clone().graphql
|ref object_boolean_expression_type| {
object_boolean_expression_type.clone().graphql
},
)
{
@ -196,10 +196,10 @@ pub fn build_boolean_expression_input_schema(
target_model_name: target_model.model.name.clone(),
relationship_type: relationship_type.clone(),
mappings: mappings.clone(),
source_data_connector: boolean_expression_type
source_data_connector: object_boolean_expression_type
.data_connector_link
.clone(),
source_type_mappings: boolean_expression_type
source_type_mappings: object_boolean_expression_type
.type_mappings
.clone(),
};

View File

@ -73,11 +73,11 @@ pub(crate) fn generate_select_many_arguments(
}
// generate and insert where argument
if let Some(boolean_expression_type) = &model.model.filter_expression_type {
if let Some(boolean_expression) = &boolean_expression_type.graphql {
if let Some(object_boolean_expression_type) = &model.model.filter_expression_type {
if let Some(boolean_expression) = &object_boolean_expression_type.graphql {
let where_argument = get_where_expression_input_field(
builder,
boolean_expression_type.name.clone(),
object_boolean_expression_type.name.clone(),
boolean_expression,
);

View File

@ -73,7 +73,7 @@ fn get_custom_input_type(
gds_type_name,
&gds.metadata.object_types,
&gds.metadata.scalar_types,
&gds.metadata.boolean_expression_types,
&gds.metadata.object_boolean_expression_types,
)
.map_err(|_| crate::Error::InternalTypeNotFound {
type_name: gds_type_name.clone(),

View File

@ -112,7 +112,7 @@ pub fn get_custom_output_type(
gds_type,
&gds.metadata.object_types,
&gds.metadata.scalar_types,
&gds.metadata.boolean_expression_types,
&gds.metadata.object_boolean_expression_types,
)
.map_err(|_| crate::Error::InternalTypeNotFound {
type_name: gds_type.clone(),
@ -158,7 +158,7 @@ pub(crate) fn get_type_kind(
type_name,
&gds.metadata.object_types,
&gds.metadata.scalar_types,
&gds.metadata.boolean_expression_types,
&gds.metadata.object_boolean_expression_types,
)
.map_err(|_| Error::InternalTypeNotFound {
type_name: type_name.to_owned(),