mirror of
https://github.com/hasura/graphql-engine.git
synced 2025-01-05 22:34:22 +03:00
Add scalar boolean expression types to data_connector_scalar_types
(#778)
<!-- The PR description should answer 2 (maybe 3) important questions: --> ### What Changed tests to use the new `BooleanExpressionType` until something broke. Fortunately something broke - we need to add the scalar boolean expression types to the data connector scalar types for various lookups. <!-- What is this PR trying to accomplish (and why, if it's not obvious)? --> <!-- Consider: do we need to add a changelog entry? --> ### How Split scalar boolean expression type resolve into own step so it's available earlier in the pipeline. Loop through them and add them to the `data_connector_scalar_types` outputs. <!-- How is it trying to accomplish it (what are the implementation steps)? --> V3_GIT_ORIGIN_REV_ID: dbd8969c3e9e9d8db1d4a34e93aefc34bdf31421
This commit is contained in:
parent
a47327a9bf
commit
bd3bc77808
@ -4,6 +4,28 @@
|
|||||||
{
|
{
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"objects": [
|
"objects": [
|
||||||
|
{
|
||||||
|
"kind": "DataConnectorScalarRepresentation",
|
||||||
|
"version": "v1",
|
||||||
|
"definition": {
|
||||||
|
"dataConnectorName": "custom",
|
||||||
|
"dataConnectorScalarType": "String",
|
||||||
|
"representation": "String",
|
||||||
|
"graphql": {
|
||||||
|
"comparisonExpressionTypeName": "String_Comparison_Exp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "DataConnectorScalarRepresentation",
|
||||||
|
"version": "v1",
|
||||||
|
"definition": {
|
||||||
|
"dataConnectorName": "custom",
|
||||||
|
"dataConnectorScalarType": "Int",
|
||||||
|
"representation": "Int"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"kind": "TypePermissions",
|
"kind": "TypePermissions",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
|
@ -4,27 +4,6 @@
|
|||||||
{
|
{
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"objects": [
|
"objects": [
|
||||||
{
|
|
||||||
"kind": "DataConnectorScalarRepresentation",
|
|
||||||
"version": "v1",
|
|
||||||
"definition": {
|
|
||||||
"dataConnectorName": "custom",
|
|
||||||
"dataConnectorScalarType": "String",
|
|
||||||
"representation": "String",
|
|
||||||
"graphql": {
|
|
||||||
"comparisonExpressionTypeName": "String_Comparison_Exp"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind": "DataConnectorScalarRepresentation",
|
|
||||||
"version": "v1",
|
|
||||||
"definition": {
|
|
||||||
"dataConnectorName": "custom",
|
|
||||||
"dataConnectorScalarType": "Int",
|
|
||||||
"representation": "Int"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"kind": "ObjectType",
|
"kind": "ObjectType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
|
@ -52,33 +52,36 @@
|
|||||||
"kind": "ObjectType"
|
"kind": "ObjectType"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "ObjectBooleanExpressionType",
|
"kind": "BooleanExpressionType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
"definition": {
|
"definition": {
|
||||||
"name": "album_bool_exp",
|
"name": "album_bool_exp",
|
||||||
"objectType": "Album",
|
"operand": {
|
||||||
"dataConnectorName": "db",
|
"object": {
|
||||||
"dataConnectorObjectType": "Album",
|
"type": "Album",
|
||||||
"comparableFields": [
|
"comparableFields": [
|
||||||
{
|
{
|
||||||
"fieldName": "AlbumId",
|
"fieldName": "AlbumId",
|
||||||
"operators": {
|
"booleanExpressionType": "int_bool_exp"
|
||||||
"enableAll": true
|
},
|
||||||
}
|
{
|
||||||
},
|
"fieldName": "ArtistId",
|
||||||
{
|
"booleanExpressionType": "int_bool_exp"
|
||||||
"fieldName": "ArtistId",
|
},
|
||||||
"operators": {
|
{
|
||||||
"enableAll": true
|
"fieldName": "Title",
|
||||||
}
|
"booleanExpressionType": "string_bool_exp"
|
||||||
},
|
}
|
||||||
{
|
],
|
||||||
"fieldName": "Title",
|
"comparableRelationships": [
|
||||||
"operators": {
|
{ "relationshipName": "Tracks" },
|
||||||
"enableAll": true
|
{ "relationshipName": "Artist" }
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true },
|
||||||
|
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"typeName": "Album_Where_Exp"
|
"typeName": "Album_Where_Exp"
|
||||||
}
|
}
|
||||||
@ -141,39 +144,37 @@
|
|||||||
"kind": "ObjectType"
|
"kind": "ObjectType"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "ObjectBooleanExpressionType",
|
"kind": "BooleanExpressionType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
"definition": {
|
"definition": {
|
||||||
"name": "track_bool_exp",
|
"name": "track_bool_exp",
|
||||||
"objectType": "Track",
|
"operand": {
|
||||||
"dataConnectorName": "db",
|
"object": {
|
||||||
"dataConnectorObjectType": "Track",
|
"type": "Track",
|
||||||
"comparableFields": [
|
"comparableFields": [
|
||||||
{
|
{
|
||||||
"fieldName": "AlbumId",
|
"fieldName": "AlbumId",
|
||||||
"operators": {
|
"booleanExpressionType": "int_bool_exp"
|
||||||
"enableAll": true
|
},
|
||||||
}
|
{
|
||||||
},
|
"fieldName": "TrackId",
|
||||||
{
|
"booleanExpressionType": "int_bool_exp"
|
||||||
"fieldName": "TrackId",
|
},
|
||||||
"operators": {
|
{
|
||||||
"enableAll": true
|
"fieldName": "Name",
|
||||||
}
|
"booleanExpressionType": "string_bool_exp"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldName": "Name",
|
"fieldName": "GenreId",
|
||||||
"operators": {
|
"booleanExpressionType": "int_bool_exp"
|
||||||
"enableAll": true
|
}
|
||||||
}
|
],
|
||||||
},
|
"comparableRelationships": [{ "relationshipName": "Album" }]
|
||||||
{
|
|
||||||
"fieldName": "GenreId",
|
|
||||||
"operators": {
|
|
||||||
"enableAll": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true },
|
||||||
|
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"typeName": "Track_Where_Exp"
|
"typeName": "Track_Where_Exp"
|
||||||
}
|
}
|
||||||
@ -218,44 +219,34 @@
|
|||||||
"kind": "ObjectType"
|
"kind": "ObjectType"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "ObjectBooleanExpressionType",
|
"kind": "BooleanExpressionType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
"definition": {
|
"definition": {
|
||||||
"name": "genre_bool_exp",
|
"name": "genre_bool_exp",
|
||||||
"objectType": "Genre",
|
"operand": {
|
||||||
"dataConnectorName": "db",
|
"object": {
|
||||||
"dataConnectorObjectType": "Genre",
|
"type": "Genre",
|
||||||
"comparableFields": [
|
"comparableFields": [
|
||||||
{
|
{
|
||||||
"fieldName": "Name",
|
"fieldName": "Name",
|
||||||
"operators": {
|
"booleanExpressionType": "string_bool_exp"
|
||||||
"enableAll": true
|
},
|
||||||
}
|
{
|
||||||
},
|
"fieldName": "GenreId",
|
||||||
{
|
"booleanExpressionType": "int_bool_exp"
|
||||||
"fieldName": "GenreId",
|
}
|
||||||
"operators": {
|
],
|
||||||
"enableAll": true
|
"comparableRelationships": []
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true },
|
||||||
|
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"typeName": "Genre_Where_Exp"
|
"typeName": "Genre_Where_Exp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"kind": "DataConnectorScalarRepresentation",
|
|
||||||
"version": "v1",
|
|
||||||
"definition": {
|
|
||||||
"dataConnectorName": "db",
|
|
||||||
"dataConnectorScalarType": "String",
|
|
||||||
"representation": "String",
|
|
||||||
"graphql": {
|
|
||||||
"comparisonExpressionTypeName": "String_Comparison_Exp"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"kind": "ScalarType",
|
"kind": "ScalarType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
@ -630,28 +621,86 @@
|
|||||||
"version": "v1",
|
"version": "v1",
|
||||||
"kind": "ObjectType"
|
"kind": "ObjectType"
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"kind": "ObjectBooleanExpressionType",
|
"kind": "BooleanExpressionType",
|
||||||
|
"version": "v1",
|
||||||
|
"definition": {
|
||||||
|
"name": "string_bool_exp",
|
||||||
|
"operand": {
|
||||||
|
"scalar": {
|
||||||
|
"type": "String",
|
||||||
|
"comparisonOperators": [
|
||||||
|
{ "name": "_eq", "argumentType": "String!" }
|
||||||
|
],
|
||||||
|
"dataConnectorOperatorMapping": [
|
||||||
|
{
|
||||||
|
"dataConnectorName": "db",
|
||||||
|
"dataConnectorScalarType": "String",
|
||||||
|
"operatorMapping": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true },
|
||||||
|
|
||||||
|
"graphql": {
|
||||||
|
"typeName": "String_Comparison_Exp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "BooleanExpressionType",
|
||||||
|
"version": "v1",
|
||||||
|
"definition": {
|
||||||
|
"name": "int_bool_exp",
|
||||||
|
"operand": {
|
||||||
|
"scalar": {
|
||||||
|
"type": "Int",
|
||||||
|
"comparisonOperators": [
|
||||||
|
{ "name": "_eq", "argumentType": "Int!" }
|
||||||
|
],
|
||||||
|
"dataConnectorOperatorMapping": [
|
||||||
|
{
|
||||||
|
"dataConnectorName": "db",
|
||||||
|
"dataConnectorScalarType": "Int",
|
||||||
|
"operatorMapping": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true },
|
||||||
|
"graphql": {
|
||||||
|
"typeName": "Int_Comparison_Exp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"kind": "BooleanExpressionType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
"definition": {
|
"definition": {
|
||||||
"name": "artist_bool_exp",
|
"name": "artist_bool_exp",
|
||||||
"objectType": "Artist",
|
"operand": {
|
||||||
"dataConnectorName": "db",
|
"object": {
|
||||||
"dataConnectorObjectType": "Artist",
|
"type": "Artist",
|
||||||
"comparableFields": [
|
"comparableFields": [
|
||||||
{
|
{
|
||||||
"fieldName": "ArtistId",
|
"fieldName": "ArtistId",
|
||||||
"operators": {
|
"booleanExpressionType": "int_bool_exp"
|
||||||
"enableAll": true
|
},
|
||||||
}
|
{
|
||||||
},
|
"fieldName": "Name",
|
||||||
{
|
"booleanExpressionType": "string_bool_exp"
|
||||||
"fieldName": "Name",
|
}
|
||||||
"operators": {
|
],
|
||||||
"enableAll": true
|
"comparableRelationships": []
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true },
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"typeName": "Artist_Where_Exp"
|
"typeName": "Artist_Where_Exp"
|
||||||
}
|
}
|
||||||
@ -780,18 +829,6 @@
|
|||||||
},
|
},
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
"kind": "Relationship"
|
"kind": "Relationship"
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind": "DataConnectorScalarRepresentation",
|
|
||||||
"version": "v1",
|
|
||||||
"definition": {
|
|
||||||
"dataConnectorName": "db",
|
|
||||||
"dataConnectorScalarType": "Int",
|
|
||||||
"representation": "Int",
|
|
||||||
"graphql": {
|
|
||||||
"comparisonExpressionTypeName": "Int_comparison"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -5,26 +5,58 @@
|
|||||||
"name": "default",
|
"name": "default",
|
||||||
"objects": [
|
"objects": [
|
||||||
{
|
{
|
||||||
"kind": "DataConnectorScalarRepresentation",
|
"kind": "BooleanExpressionType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
"definition": {
|
"definition": {
|
||||||
"dataConnectorName": "db",
|
"name": "string_bool_exp",
|
||||||
"dataConnectorScalarType": "String",
|
"operand": {
|
||||||
"representation": "String",
|
"scalar": {
|
||||||
|
"type": "String",
|
||||||
|
"comparisonOperators": [
|
||||||
|
{ "name": "_eq", "argumentType": "String!" }
|
||||||
|
],
|
||||||
|
"dataConnectorOperatorMapping": [
|
||||||
|
{
|
||||||
|
"dataConnectorName": "db",
|
||||||
|
"dataConnectorScalarType": "String",
|
||||||
|
"operatorMapping": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true },
|
||||||
|
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"comparisonExpressionTypeName": "String_Comparison_Exp"
|
"typeName": "String_Comparison_Exp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "DataConnectorScalarRepresentation",
|
"kind": "BooleanExpressionType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
"definition": {
|
"definition": {
|
||||||
"dataConnectorName": "db",
|
"name": "int_bool_exp",
|
||||||
"dataConnectorScalarType": "Int",
|
"operand": {
|
||||||
"representation": "Int"
|
"scalar": {
|
||||||
|
"type": "Int",
|
||||||
|
"comparisonOperators": [
|
||||||
|
{ "name": "_eq", "argumentType": "Int!" }
|
||||||
|
],
|
||||||
|
"dataConnectorOperatorMapping": [
|
||||||
|
{
|
||||||
|
"dataConnectorName": "db",
|
||||||
|
"dataConnectorScalarType": "Int",
|
||||||
|
"operatorMapping": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"kind": "ObjectType",
|
"kind": "ObjectType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
@ -73,33 +105,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "ObjectBooleanExpressionType",
|
"kind": "BooleanExpressionType",
|
||||||
"version": "v1",
|
"version": "v1",
|
||||||
"definition": {
|
"definition": {
|
||||||
"name": "author_bool_exp",
|
"name": "author_bool_exp",
|
||||||
"objectType": "author",
|
"operand": {
|
||||||
"dataConnectorName": "db",
|
"object": {
|
||||||
"dataConnectorObjectType": "author",
|
"type": "author",
|
||||||
"comparableFields": [
|
"comparableFields": [
|
||||||
{
|
{
|
||||||
"fieldName": "author_id",
|
"fieldName": "author_id",
|
||||||
"operators": {
|
"booleanExpressionType": "int_bool_exp"
|
||||||
"enableAll": true
|
},
|
||||||
}
|
{
|
||||||
},
|
"fieldName": "first_name",
|
||||||
{
|
"booleanExpressionType": "string_bool_exp"
|
||||||
"fieldName": "first_name",
|
},
|
||||||
"operators": {
|
{
|
||||||
"enableAll": true
|
"fieldName": "last_name",
|
||||||
}
|
"booleanExpressionType": "string_bool_exp"
|
||||||
},
|
}
|
||||||
{
|
],
|
||||||
"fieldName": "last_name",
|
"comparableRelationships": []
|
||||||
"operators": {
|
|
||||||
"enableAll": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
|
"logicalOperators": { "enable": true },
|
||||||
|
"isNull": { "enable": true },
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"typeName": "Author_Filter"
|
"typeName": "Author_Filter"
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
use crate::types::error::{BooleanExpressionError, Error, TypePredicateError};
|
use crate::types::error::{BooleanExpressionError, Error, TypePredicateError};
|
||||||
|
|
||||||
use crate::stages::{boolean_expressions, data_connectors, models, relationships};
|
use crate::stages::{
|
||||||
|
boolean_expressions, data_connectors, models, relationships, scalar_boolean_expressions,
|
||||||
|
};
|
||||||
use crate::types::subgraph::Qualified;
|
use crate::types::subgraph::Qualified;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use open_dds::{
|
use open_dds::{
|
||||||
@ -170,7 +172,7 @@ fn validate_data_connector_with_comparable_relationship(
|
|||||||
|
|
||||||
// check that a scalar BooleanExpressionType has info for whichever data connector we are using
|
// check that a scalar BooleanExpressionType has info for whichever data connector we are using
|
||||||
fn validate_data_connector_with_scalar_boolean_expression_type(
|
fn validate_data_connector_with_scalar_boolean_expression_type(
|
||||||
scalar_boolean_expression_type: &boolean_expressions::ResolvedScalarBooleanExpressionType,
|
scalar_boolean_expression_type: &scalar_boolean_expressions::ResolvedScalarBooleanExpressionType,
|
||||||
parent_boolean_expression_type_name: &Qualified<CustomTypeName>,
|
parent_boolean_expression_type_name: &Qualified<CustomTypeName>,
|
||||||
data_connector: &data_connectors::DataConnectorLink,
|
data_connector: &data_connectors::DataConnectorLink,
|
||||||
field_name: &FieldName,
|
field_name: &FieldName,
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
use crate::stages::{boolean_expressions, object_boolean_expressions, relationships, scalar_types};
|
use crate::stages::{
|
||||||
|
boolean_expressions, object_boolean_expressions, relationships, scalar_boolean_expressions,
|
||||||
|
scalar_types,
|
||||||
|
};
|
||||||
use crate::types::error::{BooleanExpressionError, Error};
|
use crate::types::error::{BooleanExpressionError, Error};
|
||||||
|
|
||||||
use crate::types::subgraph::{
|
use crate::types::subgraph::{
|
||||||
@ -45,7 +48,7 @@ pub enum TypeRepresentation<'a, ObjectType> {
|
|||||||
/// New object boolean expression type
|
/// New object boolean expression type
|
||||||
BooleanExpressionObject(&'a boolean_expressions::ResolvedObjectBooleanExpressionType),
|
BooleanExpressionObject(&'a boolean_expressions::ResolvedObjectBooleanExpressionType),
|
||||||
/// New scalar boolean expression type
|
/// New scalar boolean expression type
|
||||||
BooleanExpressionScalar(&'a boolean_expressions::ResolvedScalarBooleanExpressionType),
|
BooleanExpressionScalar(&'a scalar_boolean_expressions::ResolvedScalarBooleanExpressionType),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// validate whether a given CustomTypeName exists within `object_types`, `scalar_types` or
|
/// validate whether a given CustomTypeName exists within `object_types`, `scalar_types` or
|
||||||
|
@ -24,7 +24,7 @@ pub use stages::aggregates::{
|
|||||||
pub use stages::boolean_expressions::{
|
pub use stages::boolean_expressions::{
|
||||||
BooleanExpressionComparableRelationship, BooleanExpressionGraphqlConfig,
|
BooleanExpressionComparableRelationship, BooleanExpressionGraphqlConfig,
|
||||||
ComparisonExpressionInfo, IncludeLogicalOperators, ObjectComparisonExpressionInfo,
|
ComparisonExpressionInfo, IncludeLogicalOperators, ObjectComparisonExpressionInfo,
|
||||||
ResolvedObjectBooleanExpressionType, ResolvedScalarBooleanExpressionType,
|
ResolvedObjectBooleanExpressionType,
|
||||||
};
|
};
|
||||||
pub use stages::command_permissions::CommandWithPermissions;
|
pub use stages::command_permissions::CommandWithPermissions;
|
||||||
pub use stages::commands::Command;
|
pub use stages::commands::Command;
|
||||||
@ -34,6 +34,7 @@ pub use stages::model_permissions::{
|
|||||||
FilterPermission, ModelPredicate, ModelTargetSource, ModelWithPermissions, SelectPermission,
|
FilterPermission, ModelPredicate, ModelTargetSource, ModelWithPermissions, SelectPermission,
|
||||||
};
|
};
|
||||||
pub use stages::models::{ConnectorArgumentName, Model, ModelSource};
|
pub use stages::models::{ConnectorArgumentName, Model, ModelSource};
|
||||||
|
pub use stages::scalar_boolean_expressions::ResolvedScalarBooleanExpressionType;
|
||||||
|
|
||||||
pub use stages::models_graphql::{
|
pub use stages::models_graphql::{
|
||||||
ModelExpressionType, ModelOrderByExpression, SelectAggregateGraphQlDefinition,
|
ModelExpressionType, ModelOrderByExpression, SelectAggregateGraphQlDefinition,
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
use super::helpers;
|
use super::helpers;
|
||||||
pub use super::{
|
pub use super::{
|
||||||
BooleanExpressionComparableRelationship, BooleanExpressionGraphqlConfig,
|
BooleanExpressionComparableRelationship, BooleanExpressionGraphqlConfig,
|
||||||
BooleanExpressionGraphqlFieldConfig, ComparisonExpressionInfo, IncludeIsNull,
|
BooleanExpressionGraphqlFieldConfig, ComparisonExpressionInfo, ObjectComparisonExpressionInfo,
|
||||||
ObjectComparisonExpressionInfo, ResolvedScalarBooleanExpressionType,
|
|
||||||
};
|
};
|
||||||
use crate::helpers::types::mk_name;
|
use crate::helpers::types::mk_name;
|
||||||
use crate::stages::graphql_config;
|
use crate::stages::{graphql_config, scalar_boolean_expressions};
|
||||||
use crate::types::error::{Error, GraphqlConfigError};
|
use crate::types::error::{Error, GraphqlConfigError};
|
||||||
use crate::types::subgraph::mk_qualified_type_reference;
|
use crate::types::subgraph::mk_qualified_type_reference;
|
||||||
use crate::Qualified;
|
use crate::Qualified;
|
||||||
@ -29,7 +28,7 @@ pub(crate) fn resolve_object_boolean_graphql(
|
|||||||
comparable_relationships: &BTreeMap<FieldName, BooleanExpressionComparableRelationship>,
|
comparable_relationships: &BTreeMap<FieldName, BooleanExpressionComparableRelationship>,
|
||||||
scalar_boolean_expression_types: &BTreeMap<
|
scalar_boolean_expression_types: &BTreeMap<
|
||||||
Qualified<CustomTypeName>,
|
Qualified<CustomTypeName>,
|
||||||
ResolvedScalarBooleanExpressionType,
|
scalar_boolean_expressions::ResolvedScalarBooleanExpressionType,
|
||||||
>,
|
>,
|
||||||
raw_boolean_expression_types: &super::object::RawBooleanExpressionTypes,
|
raw_boolean_expression_types: &super::object::RawBooleanExpressionTypes,
|
||||||
subgraph: &str,
|
subgraph: &str,
|
||||||
@ -72,7 +71,8 @@ pub(crate) fn resolve_object_boolean_graphql(
|
|||||||
|
|
||||||
// Register scalar comparison field only if it contains non-zero operators.
|
// Register scalar comparison field only if it contains non-zero operators.
|
||||||
if !operators.is_empty()
|
if !operators.is_empty()
|
||||||
|| scalar_boolean_expression_type.include_is_null == IncludeIsNull::Yes
|
|| scalar_boolean_expression_type.include_is_null
|
||||||
|
== scalar_boolean_expressions::IncludeIsNull::Yes
|
||||||
{
|
{
|
||||||
scalar_fields.insert(
|
scalar_fields.insert(
|
||||||
comparable_field_name.clone(),
|
comparable_field_name.clone(),
|
||||||
@ -84,10 +84,10 @@ pub(crate) fn resolve_object_boolean_graphql(
|
|||||||
is_null_operator_name: match scalar_boolean_expression_type
|
is_null_operator_name: match scalar_boolean_expression_type
|
||||||
.include_is_null
|
.include_is_null
|
||||||
{
|
{
|
||||||
IncludeIsNull::Yes => {
|
scalar_boolean_expressions::IncludeIsNull::Yes => {
|
||||||
Some(filter_graphql_config.operator_names.is_null.clone())
|
Some(filter_graphql_config.operator_names.is_null.clone())
|
||||||
}
|
}
|
||||||
IncludeIsNull::No => None,
|
scalar_boolean_expressions::IncludeIsNull::No => None,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
use open_dds::{
|
use open_dds::{boolean_expression::BooleanExpressionLogicalOperators, types::CustomTypeName};
|
||||||
boolean_expression::{BooleanExpressionIsNull, BooleanExpressionLogicalOperators},
|
|
||||||
types::CustomTypeName,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::types::error::{BooleanExpressionError, Error};
|
use crate::types::error::{BooleanExpressionError, Error};
|
||||||
use crate::Qualified;
|
use crate::Qualified;
|
||||||
|
|
||||||
use super::types::{IncludeIsNull, IncludeLogicalOperators};
|
use super::types::IncludeLogicalOperators;
|
||||||
|
|
||||||
pub(crate) fn lookup_raw_boolean_expression<'a>(
|
pub(crate) fn lookup_raw_boolean_expression<'a>(
|
||||||
parent_boolean_expression_name: &Qualified<CustomTypeName>,
|
parent_boolean_expression_name: &Qualified<CustomTypeName>,
|
||||||
@ -30,15 +27,7 @@ pub(crate) fn lookup_raw_boolean_expression<'a>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resolve_is_null(is_null: &BooleanExpressionIsNull) -> IncludeIsNull {
|
pub fn resolve_logical_operators(
|
||||||
if is_null.enable {
|
|
||||||
IncludeIsNull::Yes
|
|
||||||
} else {
|
|
||||||
IncludeIsNull::No
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn resolve_logical_operators(
|
|
||||||
logical_operators: &BooleanExpressionLogicalOperators,
|
logical_operators: &BooleanExpressionLogicalOperators,
|
||||||
) -> IncludeLogicalOperators {
|
) -> IncludeLogicalOperators {
|
||||||
if logical_operators.enable {
|
if logical_operators.enable {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
mod graphql;
|
mod graphql;
|
||||||
mod helpers;
|
mod helpers;
|
||||||
mod object;
|
mod object;
|
||||||
mod scalar;
|
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
@ -9,7 +8,7 @@ use std::collections::{BTreeMap, BTreeSet};
|
|||||||
use lang_graphql::ast::common as ast;
|
use lang_graphql::ast::common as ast;
|
||||||
use open_dds::{boolean_expression::BooleanExpressionOperand, types::CustomTypeName};
|
use open_dds::{boolean_expression::BooleanExpressionOperand, types::CustomTypeName};
|
||||||
|
|
||||||
use crate::stages::{data_connectors, graphql_config, type_permissions};
|
use crate::stages::{graphql_config, scalar_boolean_expressions, type_permissions};
|
||||||
use crate::types::configuration::Configuration;
|
use crate::types::configuration::Configuration;
|
||||||
use crate::types::error::{BooleanExpressionError, Error};
|
use crate::types::error::{BooleanExpressionError, Error};
|
||||||
use crate::Qualified;
|
use crate::Qualified;
|
||||||
@ -17,17 +16,19 @@ use crate::Qualified;
|
|||||||
pub use types::{
|
pub use types::{
|
||||||
BooleanExpressionComparableRelationship, BooleanExpressionGraphqlConfig,
|
BooleanExpressionComparableRelationship, BooleanExpressionGraphqlConfig,
|
||||||
BooleanExpressionGraphqlFieldConfig, BooleanExpressionTypes, BooleanExpressionsOutput,
|
BooleanExpressionGraphqlFieldConfig, BooleanExpressionTypes, BooleanExpressionsOutput,
|
||||||
ComparisonExpressionInfo, IncludeIsNull, IncludeLogicalOperators,
|
ComparisonExpressionInfo, IncludeLogicalOperators, ObjectComparisonExpressionInfo,
|
||||||
ObjectComparisonExpressionInfo, ResolvedObjectBooleanExpressionType,
|
ResolvedObjectBooleanExpressionType,
|
||||||
ResolvedScalarBooleanExpressionType,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn resolve(
|
pub fn resolve(
|
||||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||||
configuration: Configuration,
|
configuration: Configuration,
|
||||||
|
boolean_expression_scalar_types: &BTreeMap<
|
||||||
|
Qualified<CustomTypeName>,
|
||||||
|
scalar_boolean_expressions::ResolvedScalarBooleanExpressionType,
|
||||||
|
>,
|
||||||
existing_graphql_types: &BTreeSet<ast::TypeName>,
|
existing_graphql_types: &BTreeSet<ast::TypeName>,
|
||||||
graphql_config: &graphql_config::GraphqlConfig,
|
graphql_config: &graphql_config::GraphqlConfig,
|
||||||
data_connectors: &data_connectors::DataConnectors,
|
|
||||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||||
) -> Result<BooleanExpressionsOutput, Error> {
|
) -> Result<BooleanExpressionsOutput, Error> {
|
||||||
if !configuration
|
if !configuration
|
||||||
@ -58,32 +59,6 @@ pub fn resolve(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's resolve scalar types first
|
|
||||||
|
|
||||||
let mut boolean_expression_scalar_types = BTreeMap::new();
|
|
||||||
|
|
||||||
for (boolean_expression_type_name, (subgraph, boolean_expression_type)) in
|
|
||||||
&raw_boolean_expression_types
|
|
||||||
{
|
|
||||||
if let BooleanExpressionOperand::Scalar(boolean_expression_scalar_operand) =
|
|
||||||
&boolean_expression_type.operand
|
|
||||||
{
|
|
||||||
let scalar_boolean_expression_type = scalar::resolve_scalar_boolean_expression_type(
|
|
||||||
boolean_expression_type_name,
|
|
||||||
boolean_expression_scalar_operand,
|
|
||||||
&boolean_expression_type.is_null,
|
|
||||||
subgraph,
|
|
||||||
data_connectors,
|
|
||||||
&boolean_expression_type.graphql,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
boolean_expression_scalar_types.insert(
|
|
||||||
boolean_expression_type_name.clone(),
|
|
||||||
scalar_boolean_expression_type,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut boolean_expression_object_types = BTreeMap::new();
|
let mut boolean_expression_object_types = BTreeMap::new();
|
||||||
|
|
||||||
for (boolean_expression_type_name, (subgraph, boolean_expression_type)) in
|
for (boolean_expression_type_name, (subgraph, boolean_expression_type)) in
|
||||||
@ -99,7 +74,7 @@ pub fn resolve(
|
|||||||
subgraph,
|
subgraph,
|
||||||
&boolean_expression_type.graphql,
|
&boolean_expression_type.graphql,
|
||||||
object_types,
|
object_types,
|
||||||
&boolean_expression_scalar_types,
|
boolean_expression_scalar_types,
|
||||||
&raw_boolean_expression_types,
|
&raw_boolean_expression_types,
|
||||||
graphql_config,
|
graphql_config,
|
||||||
)?;
|
)?;
|
||||||
@ -114,7 +89,7 @@ pub fn resolve(
|
|||||||
Ok(BooleanExpressionsOutput {
|
Ok(BooleanExpressionsOutput {
|
||||||
boolean_expression_types: BooleanExpressionTypes {
|
boolean_expression_types: BooleanExpressionTypes {
|
||||||
objects: boolean_expression_object_types,
|
objects: boolean_expression_object_types,
|
||||||
scalars: boolean_expression_scalar_types,
|
scalars: boolean_expression_scalar_types.clone(),
|
||||||
},
|
},
|
||||||
graphql_types,
|
graphql_types,
|
||||||
})
|
})
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
use super::graphql;
|
use super::graphql;
|
||||||
use super::helpers;
|
use super::helpers;
|
||||||
pub use super::{
|
pub use super::{BooleanExpressionComparableRelationship, ResolvedObjectBooleanExpressionType};
|
||||||
BooleanExpressionComparableRelationship, ResolvedObjectBooleanExpressionType,
|
|
||||||
ResolvedScalarBooleanExpressionType,
|
|
||||||
};
|
|
||||||
use crate::helpers::ndc_validation::get_underlying_type_name;
|
use crate::helpers::ndc_validation::get_underlying_type_name;
|
||||||
use crate::stages::{graphql_config, object_types, type_permissions};
|
use crate::stages::{graphql_config, object_types, scalar_boolean_expressions, type_permissions};
|
||||||
use crate::types::error::{BooleanExpressionError, Error};
|
use crate::types::error::{BooleanExpressionError, Error};
|
||||||
use crate::types::subgraph::mk_qualified_type_name;
|
use crate::types::subgraph::mk_qualified_type_name;
|
||||||
use crate::Qualified;
|
use crate::Qualified;
|
||||||
@ -37,7 +34,7 @@ pub(crate) fn resolve_object_boolean_expression_type(
|
|||||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||||
scalar_boolean_expression_types: &BTreeMap<
|
scalar_boolean_expression_types: &BTreeMap<
|
||||||
Qualified<CustomTypeName>,
|
Qualified<CustomTypeName>,
|
||||||
ResolvedScalarBooleanExpressionType,
|
scalar_boolean_expressions::ResolvedScalarBooleanExpressionType,
|
||||||
>,
|
>,
|
||||||
raw_boolean_expression_types: &RawBooleanExpressionTypes,
|
raw_boolean_expression_types: &RawBooleanExpressionTypes,
|
||||||
graphql_config: &graphql_config::GraphqlConfig,
|
graphql_config: &graphql_config::GraphqlConfig,
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
|
use crate::stages::scalar_boolean_expressions;
|
||||||
use crate::types::subgraph::{Qualified, QualifiedTypeReference};
|
use crate::types::subgraph::{Qualified, QualifiedTypeReference};
|
||||||
|
use lang_graphql::ast::common as ast;
|
||||||
use open_dds::{
|
use open_dds::{
|
||||||
data_connector::{DataConnectorName, DataConnectorOperatorName},
|
data_connector::{DataConnectorName, DataConnectorOperatorName},
|
||||||
relationships::RelationshipName,
|
relationships::RelationshipName,
|
||||||
types::{CustomTypeName, FieldName, GraphQlTypeName, OperatorName, TypeReference},
|
types::{CustomTypeName, FieldName, OperatorName},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
use lang_graphql::ast::common as ast;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct BooleanExpressionTypes {
|
pub struct BooleanExpressionTypes {
|
||||||
pub objects: BTreeMap<Qualified<CustomTypeName>, ResolvedObjectBooleanExpressionType>,
|
pub objects: BTreeMap<Qualified<CustomTypeName>, ResolvedObjectBooleanExpressionType>,
|
||||||
pub scalars: BTreeMap<Qualified<CustomTypeName>, ResolvedScalarBooleanExpressionType>,
|
pub scalars: BTreeMap<
|
||||||
|
Qualified<CustomTypeName>,
|
||||||
|
scalar_boolean_expressions::ResolvedScalarBooleanExpressionType,
|
||||||
|
>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
@ -31,33 +34,6 @@ pub struct ResolvedObjectBooleanExpressionType {
|
|||||||
pub include_logical_operators: IncludeLogicalOperators,
|
pub include_logical_operators: IncludeLogicalOperators,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
|
||||||
pub struct ResolvedScalarBooleanExpressionType {
|
|
||||||
pub name: Qualified<CustomTypeName>,
|
|
||||||
|
|
||||||
/// The list of comparison operators that can used on this scalar type
|
|
||||||
pub comparison_operators: BTreeMap<OperatorName, TypeReference>,
|
|
||||||
|
|
||||||
/// The list of mappings between OpenDD operator names and the names used in the data
|
|
||||||
/// connector schema
|
|
||||||
pub data_connector_operator_mappings: BTreeMap<
|
|
||||||
Qualified<open_dds::data_connector::DataConnectorName>,
|
|
||||||
open_dds::boolean_expression::DataConnectorOperatorMapping,
|
|
||||||
>,
|
|
||||||
|
|
||||||
// optional name for exposing this in the GraphQL schema
|
|
||||||
pub graphql_name: Option<GraphQlTypeName>,
|
|
||||||
|
|
||||||
// do we allow _is_null comparisons for this type?
|
|
||||||
pub include_is_null: IncludeIsNull,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
|
||||||
pub enum IncludeIsNull {
|
|
||||||
Yes,
|
|
||||||
No,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum IncludeLogicalOperators {
|
pub enum IncludeLogicalOperators {
|
||||||
Yes,
|
Yes,
|
||||||
|
@ -15,7 +15,7 @@ use crate::helpers::types::mk_name;
|
|||||||
use crate::types::error::Error;
|
use crate::types::error::Error;
|
||||||
use crate::types::subgraph::Qualified;
|
use crate::types::subgraph::Qualified;
|
||||||
|
|
||||||
use crate::stages::{data_connectors, scalar_types};
|
use crate::stages::{data_connectors, scalar_boolean_expressions, scalar_types};
|
||||||
|
|
||||||
pub struct DataConnectorWithScalarsOutput<'a> {
|
pub struct DataConnectorWithScalarsOutput<'a> {
|
||||||
pub data_connector_scalars:
|
pub data_connector_scalars:
|
||||||
@ -24,10 +24,15 @@ pub struct DataConnectorWithScalarsOutput<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// resolve data connector scalar representations
|
/// resolve data connector scalar representations
|
||||||
|
/// also use scalar `BooleanExpressionType`s
|
||||||
pub fn resolve<'a>(
|
pub fn resolve<'a>(
|
||||||
metadata_accessor: &'a open_dds::accessor::MetadataAccessor,
|
metadata_accessor: &'a open_dds::accessor::MetadataAccessor,
|
||||||
data_connectors: &'a data_connectors::DataConnectors,
|
data_connectors: &'a data_connectors::DataConnectors,
|
||||||
scalar_types: &'a BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
scalar_types: &'a BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||||
|
scalar_boolean_expression_types: &BTreeMap<
|
||||||
|
Qualified<CustomTypeName>,
|
||||||
|
scalar_boolean_expressions::ResolvedScalarBooleanExpressionType,
|
||||||
|
>,
|
||||||
existing_graphql_types: &'a BTreeSet<ast::TypeName>,
|
existing_graphql_types: &'a BTreeSet<ast::TypeName>,
|
||||||
) -> Result<DataConnectorWithScalarsOutput<'a>, Error> {
|
) -> Result<DataConnectorWithScalarsOutput<'a>, Error> {
|
||||||
let mut graphql_types = existing_graphql_types.clone();
|
let mut graphql_types = existing_graphql_types.clone();
|
||||||
@ -65,20 +70,13 @@ pub fn resolve<'a>(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
if scalar_type.representation.is_none() {
|
if scalar_type.representation.is_none() {
|
||||||
match &scalar_type_representation.representation {
|
validate_type_name(
|
||||||
TypeName::Inbuilt(_) => {} // TODO: Validate Nullable and Array types in Inbuilt
|
&scalar_type_representation.representation,
|
||||||
TypeName::Custom(type_name) => {
|
subgraph,
|
||||||
let qualified_type_name =
|
scalar_types,
|
||||||
Qualified::new(subgraph.to_string(), type_name.to_owned());
|
scalar_type_name,
|
||||||
let _representation =
|
)?;
|
||||||
scalar_types.get(&qualified_type_name).ok_or_else(|| {
|
|
||||||
Error::ScalarTypeUnknownRepresentation {
|
|
||||||
scalar_type: scalar_type_name.clone(),
|
|
||||||
type_name: qualified_type_name,
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scalar_type.representation = Some(scalar_type_representation.representation.clone());
|
scalar_type.representation = Some(scalar_type_representation.representation.clone());
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::DuplicateDataConnectorScalarRepresentation {
|
return Err(Error::DuplicateDataConnectorScalarRepresentation {
|
||||||
@ -105,12 +103,75 @@ pub fn resolve<'a>(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for scalar_boolean_expression in scalar_boolean_expression_types.values() {
|
||||||
|
for (data_connector_name, operator_mapping) in
|
||||||
|
&scalar_boolean_expression.data_connector_operator_mappings
|
||||||
|
{
|
||||||
|
let scalar_type_name = &operator_mapping.data_connector_scalar_type;
|
||||||
|
|
||||||
|
let scalars = data_connector_scalars
|
||||||
|
.get_mut(data_connector_name)
|
||||||
|
.ok_or_else(|| Error::ScalarTypeFromUnknownDataConnector {
|
||||||
|
scalar_type: scalar_type_name.clone(),
|
||||||
|
data_connector: data_connector_name.clone(),
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let scalar_type = scalars.0.get_mut(scalar_type_name).ok_or_else(|| {
|
||||||
|
Error::UnknownScalarTypeInDataConnector {
|
||||||
|
scalar_type: scalar_type_name.clone(),
|
||||||
|
data_connector: data_connector_name.clone(),
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
|
||||||
|
validate_type_name(
|
||||||
|
&scalar_boolean_expression.representation,
|
||||||
|
&scalar_boolean_expression.name.subgraph,
|
||||||
|
scalar_types,
|
||||||
|
scalar_type_name,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// we may have multiple `BooleanExpressionType` for the same type,
|
||||||
|
// we allow it but check their OpenDD types don't conflict
|
||||||
|
if let Some(existing_representation) = &scalar_type.representation {
|
||||||
|
if *existing_representation != scalar_boolean_expression.representation {
|
||||||
|
return Err(Error::DataConnectorScalarRepresentationMismatch {
|
||||||
|
data_connector: data_connector_name.clone(),
|
||||||
|
old_representation: existing_representation.clone(),
|
||||||
|
new_representation: scalar_boolean_expression.representation.clone(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scalar_type.representation = Some(scalar_boolean_expression.representation.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DataConnectorWithScalarsOutput {
|
Ok(DataConnectorWithScalarsOutput {
|
||||||
data_connector_scalars,
|
data_connector_scalars,
|
||||||
graphql_types,
|
graphql_types,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn validate_type_name(
|
||||||
|
type_name: &TypeName,
|
||||||
|
subgraph: &str,
|
||||||
|
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||||
|
scalar_type_name: &DataConnectorScalarType,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
match type_name {
|
||||||
|
TypeName::Inbuilt(_) => {} // TODO: Validate Nullable and Array types in Inbuilt
|
||||||
|
TypeName::Custom(type_name) => {
|
||||||
|
let qualified_type_name = Qualified::new(subgraph.to_string(), type_name.to_owned());
|
||||||
|
let _representation = scalar_types.get(&qualified_type_name).ok_or_else(|| {
|
||||||
|
Error::ScalarTypeUnknownRepresentation {
|
||||||
|
scalar_type: scalar_type_name.clone(),
|
||||||
|
type_name: qualified_type_name,
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
// convert from types in previous stage to this stage
|
// convert from types in previous stage to this stage
|
||||||
fn convert_data_connectors_contexts<'a>(
|
fn convert_data_connectors_contexts<'a>(
|
||||||
old_data_connectors: &'a data_connectors::DataConnectors<'a>,
|
old_data_connectors: &'a data_connectors::DataConnectors<'a>,
|
||||||
|
@ -14,6 +14,7 @@ pub mod object_boolean_expressions;
|
|||||||
pub mod object_types;
|
pub mod object_types;
|
||||||
pub mod relationships;
|
pub mod relationships;
|
||||||
pub mod roles;
|
pub mod roles;
|
||||||
|
pub mod scalar_boolean_expressions;
|
||||||
pub mod scalar_types;
|
pub mod scalar_types;
|
||||||
pub mod type_permissions;
|
pub mod type_permissions;
|
||||||
mod types;
|
mod types;
|
||||||
@ -53,6 +54,17 @@ pub fn resolve(
|
|||||||
graphql_types,
|
graphql_types,
|
||||||
} = scalar_types::resolve(&metadata_accessor, &graphql_types)?;
|
} = scalar_types::resolve(&metadata_accessor, &graphql_types)?;
|
||||||
|
|
||||||
|
// Validate scalar `BooleanExpressionType`s
|
||||||
|
let scalar_boolean_expressions::ScalarBooleanExpressionsOutput {
|
||||||
|
graphql_types,
|
||||||
|
boolean_expression_scalar_types,
|
||||||
|
} = scalar_boolean_expressions::resolve(
|
||||||
|
&metadata_accessor,
|
||||||
|
configuration,
|
||||||
|
&graphql_types,
|
||||||
|
&data_connectors,
|
||||||
|
)?;
|
||||||
|
|
||||||
// Validate `DataConnectorScalarType` metadata. This will soon be deprecated and subsumed by
|
// Validate `DataConnectorScalarType` metadata. This will soon be deprecated and subsumed by
|
||||||
// `BooleanExpressionType`
|
// `BooleanExpressionType`
|
||||||
let data_connector_scalar_types::DataConnectorWithScalarsOutput {
|
let data_connector_scalar_types::DataConnectorWithScalarsOutput {
|
||||||
@ -62,6 +74,7 @@ pub fn resolve(
|
|||||||
&metadata_accessor,
|
&metadata_accessor,
|
||||||
&data_connectors,
|
&data_connectors,
|
||||||
&scalar_types,
|
&scalar_types,
|
||||||
|
&boolean_expression_scalar_types,
|
||||||
&graphql_types,
|
&graphql_types,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@ -69,6 +82,19 @@ pub fn resolve(
|
|||||||
let object_types_with_permissions =
|
let object_types_with_permissions =
|
||||||
type_permissions::resolve(&metadata_accessor, &object_types)?;
|
type_permissions::resolve(&metadata_accessor, &object_types)?;
|
||||||
|
|
||||||
|
// Resolve fancy new boolean expression types
|
||||||
|
let boolean_expressions::BooleanExpressionsOutput {
|
||||||
|
boolean_expression_types,
|
||||||
|
graphql_types,
|
||||||
|
} = boolean_expressions::resolve(
|
||||||
|
&metadata_accessor,
|
||||||
|
configuration,
|
||||||
|
&boolean_expression_scalar_types,
|
||||||
|
&graphql_types,
|
||||||
|
&graphql_config,
|
||||||
|
&object_types_with_permissions,
|
||||||
|
)?;
|
||||||
|
|
||||||
// Check aggregate expressions
|
// Check aggregate expressions
|
||||||
let aggregates::AggregateExpressionsOutput {
|
let aggregates::AggregateExpressionsOutput {
|
||||||
aggregate_expressions,
|
aggregate_expressions,
|
||||||
@ -97,19 +123,6 @@ pub fn resolve(
|
|||||||
&graphql_config,
|
&graphql_config,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Resolve fancy new boolean expression types
|
|
||||||
let boolean_expressions::BooleanExpressionsOutput {
|
|
||||||
boolean_expression_types,
|
|
||||||
graphql_types,
|
|
||||||
} = boolean_expressions::resolve(
|
|
||||||
&metadata_accessor,
|
|
||||||
configuration,
|
|
||||||
&graphql_types,
|
|
||||||
&graphql_config,
|
|
||||||
&data_connectors,
|
|
||||||
&object_types_with_permissions,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// Resolve models and their sources
|
// Resolve models and their sources
|
||||||
let models::ModelsOutput {
|
let models::ModelsOutput {
|
||||||
models,
|
models,
|
||||||
|
@ -0,0 +1,82 @@
|
|||||||
|
mod scalar;
|
||||||
|
mod types;
|
||||||
|
|
||||||
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
|
use lang_graphql::ast::common as ast;
|
||||||
|
use open_dds::boolean_expression::BooleanExpressionOperand;
|
||||||
|
|
||||||
|
use crate::stages::data_connectors;
|
||||||
|
use crate::types::configuration::Configuration;
|
||||||
|
use crate::types::error::{BooleanExpressionError, Error};
|
||||||
|
use crate::Qualified;
|
||||||
|
|
||||||
|
pub use types::{
|
||||||
|
IncludeIsNull, ResolvedScalarBooleanExpressionType, ScalarBooleanExpressionsOutput,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn resolve(
|
||||||
|
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||||
|
configuration: Configuration,
|
||||||
|
existing_graphql_types: &BTreeSet<ast::TypeName>,
|
||||||
|
data_connectors: &data_connectors::DataConnectors,
|
||||||
|
) -> Result<ScalarBooleanExpressionsOutput, Error> {
|
||||||
|
if !configuration
|
||||||
|
.unstable_features
|
||||||
|
.enable_boolean_expression_types
|
||||||
|
&& !metadata_accessor.boolean_expression_types.is_empty()
|
||||||
|
{
|
||||||
|
return Err(Error::BooleanExpressionError {
|
||||||
|
boolean_expression_error: BooleanExpressionError::NewBooleanExpressionTypesAreDisabled,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut raw_boolean_expression_types = BTreeMap::new();
|
||||||
|
|
||||||
|
// TODO: make sure we are adding new types here, we are almost certainly not doing this atm
|
||||||
|
let graphql_types = existing_graphql_types.clone();
|
||||||
|
|
||||||
|
// first we collect all the boolean_expression_types
|
||||||
|
// so we have a full set to refer to when resolving them
|
||||||
|
for open_dds::accessor::QualifiedObject {
|
||||||
|
subgraph,
|
||||||
|
object: boolean_expression_type,
|
||||||
|
} in &metadata_accessor.boolean_expression_types
|
||||||
|
{
|
||||||
|
raw_boolean_expression_types.insert(
|
||||||
|
Qualified::new(subgraph.to_string(), boolean_expression_type.name.clone()),
|
||||||
|
(subgraph, boolean_expression_type),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// let's resolve scalar types first
|
||||||
|
|
||||||
|
let mut boolean_expression_scalar_types = BTreeMap::new();
|
||||||
|
|
||||||
|
for (boolean_expression_type_name, (subgraph, boolean_expression_type)) in
|
||||||
|
&raw_boolean_expression_types
|
||||||
|
{
|
||||||
|
if let BooleanExpressionOperand::Scalar(boolean_expression_scalar_operand) =
|
||||||
|
&boolean_expression_type.operand
|
||||||
|
{
|
||||||
|
let scalar_boolean_expression_type = scalar::resolve_scalar_boolean_expression_type(
|
||||||
|
boolean_expression_type_name,
|
||||||
|
boolean_expression_scalar_operand,
|
||||||
|
&boolean_expression_type.is_null,
|
||||||
|
subgraph,
|
||||||
|
data_connectors,
|
||||||
|
&boolean_expression_type.graphql,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
boolean_expression_scalar_types.insert(
|
||||||
|
boolean_expression_type_name.clone(),
|
||||||
|
scalar_boolean_expression_type,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(ScalarBooleanExpressionsOutput {
|
||||||
|
boolean_expression_scalar_types,
|
||||||
|
graphql_types,
|
||||||
|
})
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
use super::helpers;
|
use super::types::{IncludeIsNull, ResolvedScalarBooleanExpressionType};
|
||||||
use super::types::ResolvedScalarBooleanExpressionType;
|
|
||||||
use crate::stages::data_connectors;
|
use crate::stages::data_connectors;
|
||||||
use crate::types::error::Error;
|
use crate::types::error::Error;
|
||||||
use crate::Qualified;
|
use crate::Qualified;
|
||||||
@ -74,8 +73,17 @@ pub(crate) fn resolve_scalar_boolean_expression_type(
|
|||||||
Ok(ResolvedScalarBooleanExpressionType {
|
Ok(ResolvedScalarBooleanExpressionType {
|
||||||
name: boolean_expression_type_name.clone(),
|
name: boolean_expression_type_name.clone(),
|
||||||
comparison_operators: resolved_comparison_operators,
|
comparison_operators: resolved_comparison_operators,
|
||||||
|
representation: scalar_boolean_expression_operand.r#type.clone(),
|
||||||
data_connector_operator_mappings,
|
data_connector_operator_mappings,
|
||||||
include_is_null: helpers::resolve_is_null(is_null),
|
include_is_null: resolve_is_null(is_null),
|
||||||
graphql_name,
|
graphql_name,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn resolve_is_null(is_null: &BooleanExpressionIsNull) -> IncludeIsNull {
|
||||||
|
if is_null.enable {
|
||||||
|
IncludeIsNull::Yes
|
||||||
|
} else {
|
||||||
|
IncludeIsNull::No
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
use crate::types::subgraph::Qualified;
|
||||||
|
use open_dds::types::{CustomTypeName, GraphQlTypeName, OperatorName, TypeName, TypeReference};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
|
use lang_graphql::ast::common as ast;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct ScalarBooleanExpressionsOutput {
|
||||||
|
pub boolean_expression_scalar_types:
|
||||||
|
BTreeMap<Qualified<CustomTypeName>, ResolvedScalarBooleanExpressionType>,
|
||||||
|
pub graphql_types: BTreeSet<ast::TypeName>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct ResolvedScalarBooleanExpressionType {
|
||||||
|
pub name: Qualified<CustomTypeName>,
|
||||||
|
|
||||||
|
/// The OpenDD type this scalar refers to
|
||||||
|
pub representation: TypeName,
|
||||||
|
|
||||||
|
/// The list of comparison operators that can used on this scalar type
|
||||||
|
pub comparison_operators: BTreeMap<OperatorName, TypeReference>,
|
||||||
|
|
||||||
|
/// The list of mappings between OpenDD operator names and the names used in the data
|
||||||
|
/// connector schema
|
||||||
|
pub data_connector_operator_mappings: BTreeMap<
|
||||||
|
Qualified<open_dds::data_connector::DataConnectorName>,
|
||||||
|
open_dds::boolean_expression::DataConnectorOperatorMapping,
|
||||||
|
>,
|
||||||
|
|
||||||
|
// optional name for exposing this in the GraphQL schema
|
||||||
|
pub graphql_name: Option<GraphQlTypeName>,
|
||||||
|
|
||||||
|
// do we allow _is_null comparisons for this type?
|
||||||
|
pub include_is_null: IncludeIsNull,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub enum IncludeIsNull {
|
||||||
|
Yes,
|
||||||
|
No,
|
||||||
|
}
|
@ -12,7 +12,7 @@ use open_dds::{
|
|||||||
data_connector::{DataConnectorName, DataConnectorScalarType},
|
data_connector::{DataConnectorName, DataConnectorScalarType},
|
||||||
models::ModelName,
|
models::ModelName,
|
||||||
relationships::RelationshipName,
|
relationships::RelationshipName,
|
||||||
types::{CustomTypeName, FieldName, OperatorName, TypeReference},
|
types::{CustomTypeName, FieldName, OperatorName, TypeName, TypeReference},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::helpers::{
|
use crate::helpers::{
|
||||||
@ -452,6 +452,12 @@ pub enum Error {
|
|||||||
data_connector: Qualified<DataConnectorName>,
|
data_connector: Qualified<DataConnectorName>,
|
||||||
scalar_type: DataConnectorScalarType,
|
scalar_type: DataConnectorScalarType,
|
||||||
},
|
},
|
||||||
|
#[error("conflicting type representations found for data connector {data_connector:}: {old_representation:} and {new_representation:}")]
|
||||||
|
DataConnectorScalarRepresentationMismatch {
|
||||||
|
data_connector: Qualified<DataConnectorName>,
|
||||||
|
old_representation: TypeName,
|
||||||
|
new_representation: TypeName,
|
||||||
|
},
|
||||||
#[error(
|
#[error(
|
||||||
"scalar type representation required for type {scalar_type:} in data connector {data_connector:}"
|
"scalar type representation required for type {scalar_type:} in data connector {data_connector:}"
|
||||||
)]
|
)]
|
||||||
|
@ -475,6 +475,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
Int,
|
||||||
|
),
|
||||||
comparison_operators: {
|
comparison_operators: {
|
||||||
OperatorName(
|
OperatorName(
|
||||||
"_in",
|
"_in",
|
||||||
@ -551,6 +554,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
String,
|
||||||
|
),
|
||||||
comparison_operators: {
|
comparison_operators: {
|
||||||
OperatorName(
|
OperatorName(
|
||||||
"_in",
|
"_in",
|
||||||
|
@ -1434,6 +1434,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
Int,
|
||||||
|
),
|
||||||
comparison_operators: {},
|
comparison_operators: {},
|
||||||
data_connector_operator_mappings: {
|
data_connector_operator_mappings: {
|
||||||
Qualified {
|
Qualified {
|
||||||
@ -1478,6 +1481,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
String,
|
||||||
|
),
|
||||||
comparison_operators: {},
|
comparison_operators: {},
|
||||||
data_connector_operator_mappings: {
|
data_connector_operator_mappings: {
|
||||||
Qualified {
|
Qualified {
|
||||||
|
@ -242,6 +242,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
Int,
|
||||||
|
),
|
||||||
comparison_operators: {
|
comparison_operators: {
|
||||||
OperatorName(
|
OperatorName(
|
||||||
"_in",
|
"_in",
|
||||||
@ -314,6 +317,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
String,
|
||||||
|
),
|
||||||
comparison_operators: {
|
comparison_operators: {
|
||||||
OperatorName(
|
OperatorName(
|
||||||
"_in",
|
"_in",
|
||||||
|
@ -746,6 +746,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
Int,
|
||||||
|
),
|
||||||
comparison_operators: {},
|
comparison_operators: {},
|
||||||
data_connector_operator_mappings: {
|
data_connector_operator_mappings: {
|
||||||
Qualified {
|
Qualified {
|
||||||
@ -786,6 +789,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
Int,
|
||||||
|
),
|
||||||
comparison_operators: {
|
comparison_operators: {
|
||||||
OperatorName(
|
OperatorName(
|
||||||
"within",
|
"within",
|
||||||
@ -851,6 +857,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
String,
|
||||||
|
),
|
||||||
comparison_operators: {},
|
comparison_operators: {},
|
||||||
data_connector_operator_mappings: {
|
data_connector_operator_mappings: {
|
||||||
Qualified {
|
Qualified {
|
||||||
|
@ -242,6 +242,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
Int,
|
||||||
|
),
|
||||||
comparison_operators: {
|
comparison_operators: {
|
||||||
OperatorName(
|
OperatorName(
|
||||||
"_in",
|
"_in",
|
||||||
@ -338,6 +341,9 @@ Metadata {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
representation: Inbuilt(
|
||||||
|
String,
|
||||||
|
),
|
||||||
comparison_operators: {
|
comparison_operators: {
|
||||||
OperatorName(
|
OperatorName(
|
||||||
"_in",
|
"_in",
|
||||||
|
Loading…
Reference in New Issue
Block a user