Enable BooleanExpressionTypes (#783)

<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

# BooleanExpressionType

A new metadata kind `BooleanExpressionType` can now be defined. These
can be used in place of `ObjectBooleanExpressionType` and
`DataConnectorScalarRepresentation`, and allow more granular control of
comparison operators and how they are used.

The old metadata types still work, but will eventually be deprecated.

```yaml
kind: BooleanExpressionType
version: v1
definition:
  name: album_bool_exp
  operand:
    object:
      type: Album
      comparableFields:
        - fieldName: AlbumId
          booleanExpressionType: pg_int_comparison_exp
        - fieldName: ArtistId
          booleanExpressionType: pg_int_comparison_exp_with_is_null
        - field: Address
          booleanExpressionType: address_bool_exp
      comparableRelationships:
        - relationshipName: Artist
          booleanExpressionType: artist_bool_exp
  logicalOperators:
    enable: true
  isNull:
    enable: true
  graphql:
    typeName: app_album_bool_exp
```

```yaml
kind: BooleanExpressionType
version: v1
definition:
  name: pg_int_comparison_exp
  operand:
    scalar:
      type: Int
      comparisonOperators:
        - name: equals
          argumentType: String!
        - name: _in
          argumentType: [String!]!
      dataConnectorOperatorMapping:
        - dataConnectorName: postgres_db
          dataConnectorScalarType: String
          operatorMapping:
            equals: _eq
  logicalOperators:
    enable: true
  isNull:
    enable: true
  graphql:
    typeName: app_postgres_int_bool_exp
```

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Remove feature flag, unhide JsonSchema items, fix a few missing bits of
JsonSchema the tests didn't warn us about before.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: dd3055d926fdeb7446cd57085679f2492a4358a1
This commit is contained in:
Daniel Harvey 2024-07-01 16:28:27 +01:00 committed by hasura-bot
parent ec59b4e9d3
commit 0123c558f1
14 changed files with 596 additions and 170 deletions

View File

@ -6,6 +6,66 @@
- Query Usage Analytics - usage analytics JSON data is attached to `execute`
span using `internal.query_usage_analytics` attribute
#### Boolean Expression Types
A new metadata kind `BooleanExpressionType` can now be defined. These can be
used in place of `ObjectBooleanExpressionType` and
`DataConnectorScalarRepresentation`, and allow more granular control of
comparison operators and how they are used.
```yaml
kind: BooleanExpressionType
version: v1
definition:
name: album_bool_exp
operand:
object:
type: Album
comparableFields:
- fieldName: AlbumId
booleanExpressionType: pg_int_comparison_exp
- fieldName: ArtistId
booleanExpressionType: pg_int_comparison_exp_with_is_null
- field: Address
booleanExpressionType: address_bool_exp
comparableRelationships:
- relationshipName: Artist
booleanExpressionType: artist_bool_exp
logicalOperators:
enable: true
isNull:
enable: true
graphql:
typeName: app_album_bool_exp
```
```yaml
kind: BooleanExpressionType
version: v1
definition:
name: pg_int_comparison_exp
operand:
scalar:
type: Int
comparisonOperators:
- name: equals
argumentType: String!
- name: _in
argumentType: [String!]!
dataConnectorOperatorMapping:
- dataConnectorName: postgres_db
dataConnectorScalarType: String
operatorMapping:
equals: _eq
logicalOperators:
enable: true
isNull:
enable: true
graphql:
typeName: app_postgres_int_bool_exp
```
- Add flag to (`--expose-internal-errors`) toggle whether to expose internal
errors. ([#759](https://github.com/hasura/v3-engine/pull/759))

View File

@ -8,7 +8,6 @@
)]
#[serde(rename_all = "snake_case")]
pub enum UnstableFeature {
EnableBooleanExpressionTypes,
EnableOrderByExpressions,
EnableNdcV02Support,
}
@ -20,9 +19,6 @@ pub fn resolve_unstable_features(
for unstable_feature in unstable_features {
match unstable_feature {
UnstableFeature::EnableBooleanExpressionTypes => {
features.enable_boolean_expression_types = true;
}
UnstableFeature::EnableOrderByExpressions => {
features.enable_order_by_expressions = true;
}

View File

@ -487,7 +487,6 @@ fn test_metadata_resolve_configuration() -> metadata_resolve::configuration::Con
metadata_resolve::configuration::Configuration {
allow_unknown_subgraphs: false,
unstable_features: metadata_resolve::configuration::UnstableFeatures {
enable_boolean_expression_types: true,
enable_order_by_expressions: false,
enable_ndc_v02_support: true,
},

View File

@ -9,8 +9,7 @@ use lang_graphql::ast::common as ast;
use open_dds::{boolean_expression::BooleanExpressionOperand, types::CustomTypeName};
use crate::stages::{graphql_config, scalar_boolean_expressions, type_permissions};
use crate::types::configuration::Configuration;
use crate::types::error::{BooleanExpressionError, Error};
use crate::types::error::Error;
use crate::Qualified;
pub use types::{
@ -22,7 +21,6 @@ pub use types::{
pub fn resolve(
metadata_accessor: &open_dds::accessor::MetadataAccessor,
configuration: Configuration,
boolean_expression_scalar_types: &BTreeMap<
Qualified<CustomTypeName>,
scalar_boolean_expressions::ResolvedScalarBooleanExpressionType,
@ -31,16 +29,6 @@ pub fn resolve(
graphql_config: &graphql_config::GraphqlConfig,
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
) -> Result<BooleanExpressionsOutput, 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

View File

@ -58,12 +58,7 @@ pub fn resolve(
let scalar_boolean_expressions::ScalarBooleanExpressionsOutput {
graphql_types,
boolean_expression_scalar_types,
} = scalar_boolean_expressions::resolve(
&metadata_accessor,
configuration,
&graphql_types,
&data_connectors,
)?;
} = scalar_boolean_expressions::resolve(&metadata_accessor, &graphql_types, &data_connectors)?;
// Validate `DataConnectorScalarType` metadata. This will soon be deprecated and subsumed by
// `BooleanExpressionType`
@ -88,7 +83,6 @@ pub fn resolve(
graphql_types,
} = boolean_expressions::resolve(
&metadata_accessor,
configuration,
&boolean_expression_scalar_types,
&graphql_types,
&graphql_config,

View File

@ -7,8 +7,7 @@ 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::types::error::Error;
use crate::Qualified;
pub use types::{
@ -17,20 +16,9 @@ pub use types::{
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

View File

@ -14,7 +14,6 @@ pub struct Configuration {
#[derive(Debug, Clone, Copy, Default, serde::Deserialize)]
#[serde(default, deny_unknown_fields, rename_all = "camelCase")]
pub struct UnstableFeatures {
pub enable_boolean_expression_types: bool,
pub enable_order_by_expressions: bool,
pub enable_ndc_v02_support: bool,
}

View File

@ -670,8 +670,6 @@ impl From<BooleanExpressionError> for Error {
#[derive(Debug, Error)]
pub enum BooleanExpressionError {
#[error("new boolean expression types are not enabled")]
NewBooleanExpressionTypesAreDisabled,
#[error("unknown type used in object boolean expression: {type_name:}")]
UnknownTypeInObjectBooleanExpressionType {
type_name: Qualified<CustomTypeName>,

View File

@ -16,19 +16,19 @@ fn test_passing_metadata() {
prepend_module_to_snapshot => false,
}, {
let configuration = read_test_configuration(directory)
.unwrap_or_else(|error| panic!("Could not read configuration: {error}"));
.unwrap_or_else(|error| panic!("{}: Could not read configuration: {error}",directory.display()));
let metadata_json_text = std::fs::read_to_string(path)
.unwrap_or_else(|error| panic!("Could not read file {path:?}: {error}"));
.unwrap_or_else(|error| panic!("{}: Could not read file {path:?}: {error}", directory.display()));
let metadata_json_value = serde_json::from_str(&metadata_json_text)
.unwrap_or_else(|error| panic!("Could not parse JSON: {error}"));
.unwrap_or_else(|error| panic!("{}: Could not parse JSON: {error}",directory.display()));
let metadata = open_dds::traits::OpenDd::deserialize(metadata_json_value)
.unwrap_or_else(|error| panic!("Could not deserialize metadata: {error}"));
.unwrap_or_else(|error| panic!("{}: Could not deserialize metadata: {error}", directory.display()));
let resolved = metadata_resolve::resolve(metadata, configuration)
.unwrap_or_else(|error| panic!("Could not resolve metadata: {error}"));
.unwrap_or_else(|error| panic!("{}: Could not resolve metadata: {error}",directory.display()));
insta::assert_debug_snapshot!("resolved", resolved);
});
@ -45,10 +45,10 @@ fn test_failing_metadata() {
prepend_module_to_snapshot => false,
}, {
let configuration = read_test_configuration(directory)
.unwrap_or_else(|error| panic!("Could not read configuration: {error}"));
.unwrap_or_else(|error| panic!("{}: Could not read configuration: {error}", directory.display()));
let metadata_json_text = std::fs::read_to_string(path)
.unwrap_or_else(|error| panic!("Could not read file {path:?}: {error}"));
.unwrap_or_else(|error| panic!("{}: Could not read file {path:?}: {error}", directory.display()));
match serde_json::from_str(&metadata_json_text) {
Ok(metadata_json_value) => {
@ -56,7 +56,7 @@ fn test_failing_metadata() {
Ok(metadata) => {
match metadata_resolve::resolve(metadata, configuration) {
Ok(_) => {
panic!("Unexpected success when resolving {path:?}.");
panic!("{}: Unexpected success when resolving {path:?}.", directory.display());
}
Err(msg) => {
insta::assert_snapshot!("resolve_error", msg);
@ -81,7 +81,6 @@ fn read_test_configuration(
directory: &Path,
) -> Result<configuration::Configuration, Box<dyn std::error::Error>> {
let unstable_features = configuration::UnstableFeatures {
enable_boolean_expression_types: true,
enable_order_by_expressions: false,
enable_ndc_v02_support: false,
};

View File

@ -57,8 +57,7 @@
"comparisonOperators": [
{
"name": "within",
"argumentType": "int_range",
"argumentMapping": {}
"argumentType": "int_range"
}
],
"dataConnectorOperatorMapping": [

View File

@ -336,6 +336,82 @@
}
]
},
{
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionType",
"title": "BooleanExpressionType",
"description": "Definition of a type representing a boolean expression on an OpenDD type.",
"examples": [
{
"kind": "BooleanExpressionType",
"version": "v1",
"definition": {
"name": "Album_bool_exp",
"operand": {
"object": {
"type": "Album",
"comparableFields": [
{
"fieldName": "AlbumId",
"booleanExpressionType": "pg_Int_Comparison_exp"
},
{
"fieldName": "ArtistId",
"booleanExpressionType": "pg_Int_Comparison_exp_with_is_null"
},
{
"fieldName": "Address",
"booleanExpressionType": "Address_bool_exp"
}
],
"comparableRelationships": [
{
"relationshipName": "artist",
"booleanExpressionType": "Artist_bool_exp"
}
]
}
},
"logicalOperators": {
"enable": true
},
"isNull": {
"enable": true
},
"graphql": {
"typeName": "App_Album_bool_exp"
}
}
}
],
"oneOf": [
{
"type": "object",
"required": [
"definition",
"kind",
"version"
],
"properties": {
"kind": {
"type": "string",
"enum": [
"BooleanExpressionType"
]
},
"version": {
"type": "string",
"enum": [
"v1"
]
},
"definition": {
"$ref": "#/definitions/BooleanExpressionTypeV1"
}
},
"additionalProperties": false
}
]
},
{
"$id": "https://hasura.io/jsonschemas/metadata/DataConnectorScalarRepresentation",
"title": "DataConnectorScalarRepresentation",
@ -2344,6 +2420,407 @@
},
"additionalProperties": false
},
"BooleanExpressionTypeV1": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionTypeV1",
"title": "BooleanExpressionTypeV1",
"description": "Definition of a type representing a boolean expression on an OpenDD object type.",
"type": "object",
"required": [
"isNull",
"logicalOperators",
"name",
"operand"
],
"properties": {
"name": {
"description": "The name to give this boolean expression type, used to refer to it elsewhere in the metadata. Must be unique across all types defined in this subgraph.",
"allOf": [
{
"$ref": "#/definitions/CustomTypeName"
}
]
},
"operand": {
"description": "The type that this boolean expression applies to.",
"allOf": [
{
"$ref": "#/definitions/BooleanExpressionOperand"
}
]
},
"logicalOperators": {
"description": "Whether to enable _and / _or / _not",
"allOf": [
{
"$ref": "#/definitions/BooleanExpressionLogicalOperators"
}
]
},
"isNull": {
"description": "Whether to enable _is_null",
"allOf": [
{
"$ref": "#/definitions/BooleanExpressionIsNull"
}
]
},
"graphql": {
"description": "Configuration for how this object type should appear in the GraphQL schema.",
"anyOf": [
{
"$ref": "#/definitions/BooleanExpressionTypeGraphQlConfiguration"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
},
"BooleanExpressionOperand": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionOperand",
"title": "BooleanExpressionOperand",
"description": "Configuration for object or scalar boolean expression",
"oneOf": [
{
"title": "Object",
"description": "Definition of a boolean expression on an OpenDD object type",
"type": "object",
"required": [
"object"
],
"properties": {
"object": {
"$ref": "#/definitions/BooleanExpressionObjectOperand"
}
},
"additionalProperties": false
},
{
"title": "Scalar",
"description": "Definition of a boolean expression on a scalar tyoe",
"type": "object",
"required": [
"scalar"
],
"properties": {
"scalar": {
"$ref": "#/definitions/BooleanExpressionScalarOperand"
}
},
"additionalProperties": false
}
]
},
"BooleanExpressionObjectOperand": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionObjectOperand",
"title": "BooleanExpressionObjectOperand",
"description": "Definition of an object type representing a boolean expression on an OpenDD object type.",
"type": "object",
"required": [
"comparableFields",
"comparableRelationships",
"type"
],
"properties": {
"type": {
"description": "The name of the object type that this boolean expression applies to.",
"allOf": [
{
"$ref": "#/definitions/CustomTypeName"
}
]
},
"comparableFields": {
"description": "The list of fields of the object type that can be used for comparison when evaluating this boolean expression.",
"type": "array",
"items": {
"$ref": "#/definitions/BooleanExpressionComparableField"
}
},
"comparableRelationships": {
"description": "The list of relationships of the object type that can be used for comparison when evaluating this boolean expression.",
"type": "array",
"items": {
"$ref": "#/definitions/BooleanExpressionComparableRelationship"
}
}
},
"additionalProperties": false
},
"BooleanExpressionComparableField": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionComparableField",
"title": "BooleanExpressionComparableField",
"type": "object",
"required": [
"booleanExpressionType",
"fieldName"
],
"properties": {
"fieldName": {
"$ref": "#/definitions/FieldName"
},
"booleanExpressionType": {
"$ref": "#/definitions/CustomTypeName"
}
},
"additionalProperties": false
},
"BooleanExpressionComparableRelationship": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionComparableRelationship",
"title": "BooleanExpressionComparableRelationship",
"description": "Definition of a relationship that can be used for a comparison",
"type": "object",
"required": [
"relationshipName"
],
"properties": {
"relationshipName": {
"description": "The name of the relationship to use for comparison",
"allOf": [
{
"$ref": "#/definitions/RelationshipName"
}
]
},
"booleanExpressionType": {
"description": "The boolean expression type to use for comparison. This is optional for relationships to models, and defaults to the filterExpressionType of the model",
"anyOf": [
{
"$ref": "#/definitions/CustomTypeName"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
},
"BooleanExpressionScalarOperand": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionScalarOperand",
"title": "BooleanExpressionScalarOperand",
"description": "Definition of a scalar type representing a boolean expression on an OpenDD object type.",
"type": "object",
"required": [
"comparisonOperators",
"dataConnectorOperatorMapping",
"type"
],
"properties": {
"type": {
"description": "The OpenDD type name of the scalar type that this boolean expression applies to.",
"allOf": [
{
"$ref": "#/definitions/TypeName"
}
]
},
"comparisonOperators": {
"description": "The list of comparison operators that can used on this scalar type",
"type": "array",
"items": {
"$ref": "#/definitions/ComparisonOperator"
}
},
"dataConnectorOperatorMapping": {
"description": "The list of mappings between OpenDD operator names and the names used in the data connector schema",
"type": "array",
"items": {
"$ref": "#/definitions/DataConnectorOperatorMapping"
}
}
},
"additionalProperties": false
},
"TypeName": {
"$id": "https://hasura.io/jsonschemas/metadata/TypeName",
"title": "TypeName",
"anyOf": [
{
"$ref": "#/definitions/InbuiltType"
},
{
"$ref": "#/definitions/CustomTypeName"
}
]
},
"InbuiltType": {
"$id": "https://hasura.io/jsonschemas/metadata/InbuiltType",
"title": "InbuiltType",
"description": "An inbuilt primitive OpenDD type.",
"type": "string",
"enum": [
"ID",
"Int",
"Float",
"Boolean",
"String"
]
},
"ComparisonOperator": {
"$id": "https://hasura.io/jsonschemas/metadata/ComparisonOperator",
"title": "ComparisonOperator",
"type": "object",
"required": [
"argumentType",
"name"
],
"properties": {
"name": {
"description": "Name you want to give the operator in OpenDD / GraphQL",
"allOf": [
{
"$ref": "#/definitions/OperatorName"
}
]
},
"argumentType": {
"description": "An OpenDD type",
"allOf": [
{
"$ref": "#/definitions/TypeReference"
}
]
}
},
"additionalProperties": false
},
"DataConnectorOperatorMapping": {
"$id": "https://hasura.io/jsonschemas/metadata/DataConnectorOperatorMapping",
"title": "DataConnectorOperatorMapping",
"type": "object",
"required": [
"dataConnectorName",
"dataConnectorScalarType",
"operatorMapping"
],
"properties": {
"dataConnectorName": {
"description": "Name of the data connector this mapping applies to",
"allOf": [
{
"$ref": "#/definitions/DataConnectorName"
}
]
},
"dataConnectorScalarType": {
"description": "Name of the scalar type according to the data connector's schema",
"allOf": [
{
"$ref": "#/definitions/DataConnectorScalarType"
}
]
},
"operatorMapping": {
"title": "operator_mapping",
"description": "Mapping between OpenDD operator names and the data connector's operator names Defaults to the same operator name (e.g. \"_eq: _eq\") if no explicit mapping is present.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/DataConnectorOperatorName"
}
}
},
"additionalProperties": false
},
"OpenDdSupergraphObject": {
"$id": "https://hasura.io/jsonschemas/metadata/OpenDdSupergraphObject",
"title": "OpenDdSupergraphObject",
"oneOf": [
{
"$id": "https://hasura.io/jsonschemas/metadata/GraphqlConfig",
"title": "GraphqlConfig",
"description": "GraphqlConfig object tells us two things:\n\n1. How the Graphql schema should look like for the features (`where`, `order_by` etc) Hasura provides 2. What features should be enabled/disabled across the subgraphs",
"oneOf": [
{
"type": "object",
"required": [
"definition",
"kind",
"version"
],
"properties": {
"kind": {
"type": "string",
"enum": [
"GraphqlConfig"
]
},
"version": {
"type": "string",
"enum": [
"v1"
]
},
"definition": {
"$ref": "#/definitions/GraphqlConfigV1"
}
},
"additionalProperties": false
}
]
}
]
},
"DataConnectorScalarType": {
"description": "The name of a scalar type in a data connector.",
"type": "string"
},
"DataConnectorOperatorName": {
"description": "The name of an operator in a data connector.",
"type": "string"
},
"BooleanExpressionLogicalOperators": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionLogicalOperators",
"title": "BooleanExpressionLogicalOperators",
"description": "Configuration for logical operators in boolean expressions",
"type": "object",
"required": [
"enable"
],
"properties": {
"enable": {
"type": "boolean"
}
},
"additionalProperties": false
},
"BooleanExpressionIsNull": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionIsNull",
"title": "BooleanExpressionIsNull",
"description": "Configuration for is_null in boolean expressions",
"type": "object",
"required": [
"enable"
],
"properties": {
"enable": {
"type": "boolean"
}
},
"additionalProperties": false
},
"BooleanExpressionTypeGraphQlConfiguration": {
"$id": "https://hasura.io/jsonschemas/metadata/BooleanExpressionTypeGraphQlConfiguration",
"title": "BooleanExpressionTypeGraphQlConfiguration",
"description": "GraphQL configuration of an OpenDD boolean expression type.",
"type": "object",
"required": [
"typeName"
],
"properties": {
"typeName": {
"description": "The name to use for the GraphQL type representation of this boolean expression type.",
"allOf": [
{
"$ref": "#/definitions/GraphQlTypeName"
}
]
}
},
"additionalProperties": false
},
"DataConnectorScalarRepresentationV1": {
"$id": "https://hasura.io/jsonschemas/metadata/DataConnectorScalarRepresentationV1",
"title": "DataConnectorScalarRepresentationV1",
@ -2403,36 +2880,32 @@
},
"additionalProperties": false
},
"DataConnectorScalarType": {
"$id": "https://hasura.io/jsonschemas/metadata/DataConnectorScalarType",
"title": "DataConnectorScalarType",
"description": "The name of a scalar type in a data connector.",
"type": "string"
},
"TypeName": {
"$id": "https://hasura.io/jsonschemas/metadata/TypeName",
"title": "TypeName",
"anyOf": [
{
"$ref": "#/definitions/InbuiltType"
},
{
"$ref": "#/definitions/CustomTypeName"
"OpenDdSupergraph": {
"$id": "https://hasura.io/jsonschemas/metadata/OpenDdSupergraph",
"title": "OpenDdSupergraph",
"type": "object",
"properties": {
"objects": {
"default": [],
"type": "array",
"items": {
"$ref": "#/definitions/OpenDdSupergraphObject"
}
}
]
},
"additionalProperties": false
},
"InbuiltType": {
"$id": "https://hasura.io/jsonschemas/metadata/InbuiltType",
"title": "InbuiltType",
"description": "An inbuilt primitive OpenDD type.",
"type": "string",
"enum": [
"ID",
"Int",
"Float",
"Boolean",
"String"
]
"OpenDdFlags": {
"$id": "https://hasura.io/jsonschemas/metadata/OpenDdFlags",
"title": "OpenDdFlags",
"type": "object",
"properties": {
"require_graphql_config": {
"default": false,
"type": "boolean"
}
},
"additionalProperties": false
},
"DataConnectorScalarGraphQLConfiguration": {
"$id": "https://hasura.io/jsonschemas/metadata/DataConnectorScalarGraphQLConfiguration",
@ -2664,18 +3137,6 @@
},
"additionalProperties": false
},
"OpenDdFlags": {
"$id": "https://hasura.io/jsonschemas/metadata/OpenDdFlags",
"title": "OpenDdFlags",
"type": "object",
"properties": {
"require_graphql_config": {
"default": false,
"type": "boolean"
}
},
"additionalProperties": false
},
"AggregationFunctionDefinition": {
"$id": "https://hasura.io/jsonschemas/metadata/AggregationFunctionDefinition",
"title": "AggregationFunctionDefinition",
@ -2752,60 +3213,6 @@
},
"additionalProperties": false
},
"OpenDdSupergraphObject": {
"$id": "https://hasura.io/jsonschemas/metadata/OpenDdSupergraphObject",
"title": "OpenDdSupergraphObject",
"oneOf": [
{
"$id": "https://hasura.io/jsonschemas/metadata/GraphqlConfig",
"title": "GraphqlConfig",
"description": "GraphqlConfig object tells us two things:\n\n1. How the Graphql schema should look like for the features (`where`, `order_by` etc) Hasura provides 2. What features should be enabled/disabled across the subgraphs",
"oneOf": [
{
"type": "object",
"required": [
"definition",
"kind",
"version"
],
"properties": {
"kind": {
"type": "string",
"enum": [
"GraphqlConfig"
]
},
"version": {
"type": "string",
"enum": [
"v1"
]
},
"definition": {
"$ref": "#/definitions/GraphqlConfigV1"
}
},
"additionalProperties": false
}
]
}
]
},
"OpenDdSupergraph": {
"$id": "https://hasura.io/jsonschemas/metadata/OpenDdSupergraph",
"title": "OpenDdSupergraph",
"type": "object",
"properties": {
"objects": {
"default": [],
"type": "array",
"items": {
"$ref": "#/definitions/OpenDdSupergraphObject"
}
}
},
"additionalProperties": false
},
"AggregationFunctionMappings": {
"$id": "https://hasura.io/jsonschemas/metadata/AggregationFunctionMappings",
"title": "AggregationFunctionMappings",

View File

@ -11,7 +11,7 @@ use crate::{
/// Definition of a type representing a boolean expression on an OpenDD type.
#[derive(Serialize, Clone, Debug, PartialEq, opendds_derive::OpenDd)]
#[serde(tag = "version", content = "definition")]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[opendd(
as_versioned_with_definition,
json_schema(
@ -78,7 +78,7 @@ impl BooleanExpressionType {
}
#[derive(Serialize, Clone, Debug, PartialEq, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[opendd(json_schema(title = "BooleanExpressionTypeV1",))]
/// Definition of a type representing a boolean expression on an OpenDD object type.
pub struct BooleanExpressionTypeV1 {
@ -101,7 +101,7 @@ pub struct BooleanExpressionTypeV1 {
/// Configuration for is_null in boolean expressions
#[derive(Serialize, Clone, Debug, PartialEq, Eq, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[opendd(json_schema(title = "BooleanExpressionIsNull"))]
pub struct BooleanExpressionIsNull {
pub enable: bool,
@ -109,7 +109,7 @@ pub struct BooleanExpressionIsNull {
/// Configuration for logical operators in boolean expressions
#[derive(Serialize, Clone, Debug, PartialEq, Eq, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[opendd(json_schema(title = "BooleanExpressionLogicalOperators"))]
pub struct BooleanExpressionLogicalOperators {
pub enable: bool,
@ -117,7 +117,7 @@ pub struct BooleanExpressionLogicalOperators {
/// GraphQL configuration of an OpenDD boolean expression type.
#[derive(Serialize, Clone, Debug, PartialEq, Eq, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[opendd(json_schema(title = "BooleanExpressionTypeGraphQlConfiguration"))]
pub struct BooleanExpressionTypeGraphQlConfiguration {
/// The name to use for the GraphQL type representation of this boolean expression type.
@ -125,21 +125,21 @@ pub struct BooleanExpressionTypeGraphQlConfiguration {
}
/// Configuration for object or scalar boolean expression
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, PartialEq, opendds_derive::OpenDd)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[opendd(json_schema(title = "BooleanExpressionOperand"))]
#[schemars(title = "BooleanExpressionOperand")]
pub enum BooleanExpressionOperand {
#[serde(rename = "object")]
/// Definition of a boolean expression on an OpenDD object type
#[schemars(title = "Object")]
Object(BooleanExpressionObjectOperand),
#[serde(rename = "scalar")]
/// Definition of a boolean expression on a scalar tyoe
#[schemars(title = "Scalar")]
Scalar(BooleanExpressionScalarOperand),
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase")]
#[opendd(json_schema(title = "ComparisonOperator"))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[schemars(title = "ComparisonOperator")]
pub struct ComparisonOperator {
/// Name you want to give the operator in OpenDD / GraphQL
pub name: OperatorName,
@ -151,8 +151,8 @@ pub struct ComparisonOperator {
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, opendds_derive::OpenDd,
)]
#[serde(rename_all = "camelCase")]
#[opendd(json_schema(title = "DataConnectorOperatorMapping"))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[schemars(title = "DataConnectorOperatorMapping")]
pub struct DataConnectorOperatorMapping {
/// Name of the data connector this mapping applies to
pub data_connector_name: DataConnectorName,
@ -162,13 +162,14 @@ pub struct DataConnectorOperatorMapping {
/// Mapping between OpenDD operator names and the data connector's operator names
/// Defaults to the same operator name (e.g. "_eq: _eq") if no explicit mapping is present.
#[schemars(title = "operator_mapping")]
pub operator_mapping: BTreeMap<OperatorName, DataConnectorOperatorName>,
}
/// Definition of a scalar type representing a boolean expression on an OpenDD object type.
#[derive(Serialize, Deserialize, Clone, JsonSchema, Debug, PartialEq, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase")]
#[opendd(json_schema(title = "BooleanExpressionScalarOperand"))]
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, PartialEq, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[schemars(title = "BooleanExpressionScalarOperand")]
pub struct BooleanExpressionScalarOperand {
/// The OpenDD type name of the scalar type that this boolean expression applies to.
#[opendd(rename = "type")]
@ -184,8 +185,8 @@ pub struct BooleanExpressionScalarOperand {
/// Definition of an object type representing a boolean expression on an OpenDD object type.
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, PartialEq, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase")]
#[opendd(json_schema(title = "BooleanExpressionObjectOperand"))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[schemars(title = "BooleanExpressionObjectOperand")]
pub struct BooleanExpressionObjectOperand {
/// The name of the object type that this boolean expression applies to.
#[opendd(rename = "type")]
@ -200,8 +201,8 @@ pub struct BooleanExpressionObjectOperand {
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, opendds_derive::OpenDd)]
#[serde(rename_all = "camelCase")]
#[opendd(json_schema(title = "BooleanExpressionComparableField"))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[schemars(title = "BooleanExpressionComparableField")]
pub struct BooleanExpressionComparableField {
pub field_name: FieldName,
pub boolean_expression_type: CustomTypeName,
@ -211,8 +212,8 @@ pub struct BooleanExpressionComparableField {
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, opendds_derive::OpenDd,
)]
#[serde(rename_all = "camelCase")]
#[opendd(json_schema(title = "BooleanExpressionComparableRelationship"))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[schemars(title = "BooleanExpressionComparableRelationship")]
pub struct BooleanExpressionComparableRelationship {
/// The name of the relationship to use for comparison
pub relationship_name: RelationshipName,

View File

@ -89,7 +89,6 @@ pub enum OpenDdSubgraphObject {
ObjectType(types::ObjectType),
ScalarType(types::ScalarType),
ObjectBooleanExpressionType(types::ObjectBooleanExpressionType),
#[opendd(hidden = true)]
BooleanExpressionType(boolean_expression::BooleanExpressionType),
// OrderBy Expressions

View File

@ -140,7 +140,6 @@ watch-local: start-docker-test-deps start-docker-run-deps
-x test \
-x 'clippy --no-deps' \
-x 'run --bin engine -- \
--unstable-feature enable-boolean-expression-types \
--otlp-endpoint http://localhost:4317 \
--authn-config-path auth_config.json \
--metadata-path crates/engine/tests/schema.json \