Take snapshots of passing and failing metadata resolution. (#763)

### What

In order to more easily monitor and review changes to metadata
resolution, this introduces snapshot testing for both successful and
failing calls to `resolve`. I used [Insta](https://insta.rs/) for this.

### How

For tests of the failure case, we already had a text file with the
expected error, so I have turned those files into snapshot files. I
wrote a small script to move the files rather than deleting and
recreating them so I could guarantee that the contents have not changed.
(Unfortunately, Git's diff doesn't always recognise the move as a move
because Insta has added a header.)

For tests of the successful case, I added a line to snapshot the
metadata rather than discarding it.

I also rewrote the tests to use `insta::glob` so we could get rid of
`test_each`.

V3_GIT_ORIGIN_REV_ID: 41bef4cf77bddb8d20d7c101df52ae149e8b0476
This commit is contained in:
Samir Talwar 2024-06-26 10:14:34 +02:00 committed by hasura-bot
parent 485914e52b
commit 63ac02bc07
107 changed files with 8635 additions and 123 deletions

52
v3/Cargo.lock generated
View File

@ -715,6 +715,16 @@ dependencies = [
"regex-automata 0.1.10",
]
[[package]]
name = "bstr"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "build-data"
version = "0.2.1"
@ -2033,6 +2043,19 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "globset"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1"
dependencies = [
"aho-corasick",
"bstr 1.9.1",
"log",
"regex-automata 0.4.7",
"regex-syntax",
]
[[package]]
name = "goldenfile"
version = "1.7.1"
@ -2398,9 +2421,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "810ae6042d48e2c9e9215043563a58a80b877bc863228a74cf10c49d4620a6f5"
dependencies = [
"console",
"globset",
"lazy_static",
"linked-hash-map",
"similar",
"walkdir",
]
[[package]]
@ -2753,10 +2778,10 @@ dependencies = [
name = "metadata-resolve"
version = "0.1.0"
dependencies = [
"anyhow",
"derive_more",
"hasura-authn-core",
"indexmap 2.2.6",
"insta",
"lang-graphql",
"lazy_static",
"ndc-models",
@ -2767,8 +2792,6 @@ dependencies = [
"schemars",
"serde",
"serde_json",
"similar-asserts",
"test-each",
"thiserror",
"url",
]
@ -4160,7 +4183,7 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640"
dependencies = [
"bstr",
"bstr 0.2.17",
"unicode-segmentation",
]
@ -4431,27 +4454,6 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "test-each"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d822711cf1d4a8d8adc34414c26c85f9144c692903c45a47a04ee4ffb360e5bc"
dependencies = [
"test-each-codegen",
]
[[package]]
name = "test-each-codegen"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad5bbe324addbdc5ee683822d0812e9bb63fbeabff10baf0d11fcfc7a0ff2122"
dependencies = [
"glob",
"proc-macro2",
"quote",
"syn 2.0.68",
]
[[package]]
name = "text-size"
version = "1.1.1"

View File

@ -109,12 +109,10 @@ serde_json = "1"
serde_path_to_error = "0.1"
serde_with = "3"
sha2 = "0.10"
similar-asserts = "1"
smol_str = "0.1"
strum = "0.26"
strum_macros = "0.26"
syn = "2"
test-each = "0.2"
thiserror = "1"
tokio = "1"
tokio-test = "0.4"

View File

@ -26,9 +26,7 @@ thiserror = { workspace = true }
url = { workspace = true }
[dev-dependencies]
test-each = { workspace = true }
anyhow = { workspace = true }
similar-asserts = { workspace = true }
insta = { workspace = true, features = ["glob"] }
[lints]
workspace = true

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expression_in_relationship/data_connector_lacks_nested_fields_aggregates_capability/metadata.json
---
The aggregate defined on the relationship invoiceLines on type Invoice (in subgraph default) has an error: the data connector mypg (in subgraph default) does not support aggregates over nested object fields, such as the field detail used in aggregate expression InvoiceLine_aggregate_exp (in subgraph default)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expression_in_relationship/disallow_count_distinct_on_models/metadata.json
---
The aggregate defined on the relationship invoiceLines on type Invoice (in subgraph default) has an error: the aggregate expression InvoiceLine_aggregate_exp (in subgraph default) is used with the model InvoiceLine (in subgraph default) which has the countDistinct aggregation enabled, but countDistinct is not valid when aggregating a model as every object is already logically distinct

View File

@ -1 +0,0 @@
The relationship customer on type Invoice (in subgraph default) defines an aggregate, but aggregates can only be used with array relationships, not object relationships

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expression_in_relationship/disallow_object_relationships/metadata.json
---
The relationship customer on type Invoice (in subgraph default) defines an aggregate, but aggregates can only be used with array relationships, not object relationships

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expression_in_relationship/missing_aggregate_exp/metadata.json
---
The aggregate defined on the relationship invoiceLines on type Invoice (in subgraph default) has an error: the aggregate expression Wrong_aggregate_exp (in subgraph default) used with model InvoiceLine (in subgraph default) has not been defined

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expression_in_relationship/missing_aggregation_function_mappings_to_model_data_connector/metadata.json
---
The aggregate defined on the relationship invoiceLines on type Invoice (in subgraph default) has an error: the aggregate expression Int4_aggregate_exp (in subgraph default) is used with the model InvoiceLine (in subgraph default) but for the data connector mypg (in subgraph default) and scalar type int4, mappings are not provided for all aggregation functions in the aggregate expression

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expression_in_relationship/missing_model_source/metadata.json
---
The aggregate defined on the relationship invoiceLines on type Invoice (in subgraph default) has an error: a source must be defined for model InvoiceLine (in subgraph default) in order to use aggregate expressions

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expression_in_relationship/operand_type_mismatch/metadata.json
---
The aggregate defined on the relationship invoiceLines on type Invoice (in subgraph default) has an error: the aggregate expression Invoice_aggregate_exp (in subgraph default) is used with the model InvoiceLine (in subgraph default) but its operand type Invoice (in subgraph default) does not match the model's type InvoiceLine (in subgraph default)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/aggregatable_field_agg_exp_type_mismatch/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) specifies an aggregatable field 'invoiceId' of type Int4! (in subgraph default), however the aggregation expression used to aggregate that field (Int8_aggregate_exp (in subgraph default)) is for aggregating a different type: Int8 (in subgraph default)

View File

@ -1 +0,0 @@
the aggregate expression Invoice_aggregate_exp (in subgraph default) specifies an aggregatable field 'randoField' that does not exist on its operand type Invoice (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/aggregatable_field_not_found/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) specifies an aggregatable field 'randoField' that does not exist on its operand type Invoice (in subgraph default)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/aggregation_function_return_array_type_mismatch_to_named/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_top5' which is mapped to the data connector 'mypg (in subgraph default)' but the Open DD return type [Int4] (in subgraph default) is not compatible with the data connector's return type. Reason: The data connector's return type is the named type 'int4', but the Open DD return type is an array

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/aggregation_function_return_named_type_mismatch_to_array/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_top5' which is mapped to the data connector 'mypg (in subgraph default)' but the Open DD return type Int4 (in subgraph default) is not compatible with the data connector's return type. Reason: The data connector's return type is an array, but the Open DD return type is not

View File

@ -1 +0,0 @@
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_sum' which is mapped to the data connector 'mypg (in subgraph default)' but the Open DD return type Int8! (in subgraph default) is not compatible with the data connector's return type. Reason: The data connector's return type is nullable, but the Open DD return type is not

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/aggregation_function_return_nullability_mismatch_with_data_connector/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_sum' which is mapped to the data connector 'mypg (in subgraph default)' but the Open DD return type Int8! (in subgraph default) is not compatible with the data connector's return type. Reason: The data connector's return type is nullable, but the Open DD return type is not

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/aggregation_function_return_object_missing_mapping/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_minmax' which is mapped to the data connector 'mypg (in subgraph default)' but the Open DD return type MinMax (in subgraph default) is not compatible with the data connector's return type. Reason: There is no type mapping defined from the Open DD return object type to the data connector's object type 'MinMax'

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/aggregation_function_return_type_repr_mismatch/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_sum' which is mapped to the data connector 'mypg (in subgraph default)' but the Open DD return type Int4! (in subgraph default) is not compatible with the data connector's return type. Reason: The data connector's return scalar type representation (Int8 (in subgraph default)) does not match the Open DD return type

View File

@ -1 +0,0 @@
the name used by query.aggregate.countFieldName from the GraphqlConfig conflicts with the aggregatable field name _count in the aggregate expression Invoice_aggregate_exp (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/conflict_between_count_and_aggregatable_field/metadata.json
---
the name used by query.aggregate.countFieldName from the GraphqlConfig conflicts with the aggregatable field name _count in the aggregate expression Invoice_aggregate_exp (in subgraph default)

View File

@ -1 +0,0 @@
the name used by query.aggregate.countFieldName from the GraphqlConfig conflicts with the aggregation function name _count in the aggregate expression Int4_aggregate_exp (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/conflict_between_count_and_aggregation_function/metadata.json
---
the name used by query.aggregate.countFieldName from the GraphqlConfig conflicts with the aggregation function name _count in the aggregate expression Int4_aggregate_exp (in subgraph default)

View File

@ -1 +0,0 @@
the name used by query.aggregate.countDistinctFieldName from the GraphqlConfig conflicts with the aggregatable field name _count_distinct in the aggregate expression Invoice_aggregate_exp (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/conflict_between_count_distinct_and_aggregatable_field/metadata.json
---
the name used by query.aggregate.countDistinctFieldName from the GraphqlConfig conflicts with the aggregatable field name _count_distinct in the aggregate expression Invoice_aggregate_exp (in subgraph default)

View File

@ -1 +0,0 @@
the name used by query.aggregate.countDistinctFieldName from the GraphqlConfig conflicts with the aggregation function name _count_distinct in the aggregate expression Int4_aggregate_exp (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/conflict_between_count_distinct_and_aggregation_function/metadata.json
---
the name used by query.aggregate.countDistinctFieldName from the GraphqlConfig conflicts with the aggregation function name _count_distinct in the aggregate expression Int4_aggregate_exp (in subgraph default)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/data_connector_function_return_not_a_scalar/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_min' which is mapped to the data connector 'mypg (in subgraph default)' but the Open DD return type Int4! (in subgraph default) is not compatible with the data connector's return type. Reason: The data connector's return type (Invoice) isn't a scalar type

View File

@ -1 +0,0 @@
the aggregate expression Int4_aggregate_exp (in subgraph default) defines an aggregation function mapping to a data connector that does not support aggregates: mypg (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/data_connector_lacks_aggregates_capability/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) defines an aggregation function mapping to a data connector that does not support aggregates: mypg (in subgraph default)

View File

@ -1 +0,0 @@
the data connector mypg (in subgraph default) does not support aggregates over nested object fields, such as the field billingAddress used in aggregate expression Invoice_aggregate_exp (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/data_connector_lacks_nested_fields_aggregates_capability/metadata.json
---
the data connector mypg (in subgraph default) does not support aggregates over nested object fields, such as the field billingAddress used in aggregate expression Invoice_aggregate_exp (in subgraph default)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/disallow_count_distinct_on_models/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) is used with the model Invoice (in subgraph default) which has the countDistinct aggregation enabled, but countDistinct is not valid when aggregating a model as every object is already logically distinct

View File

@ -1 +0,0 @@
multiple graphql types found with the same name: App_Invoice

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/disallow_duplicate_graphql_select_type_name/metadata.json
---
multiple graphql types found with the same name: App_Invoice

View File

@ -1 +0,0 @@
multiple graphql types found with the same name: App_Invoice

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/disallow_duplicate_model_filter_input_type_name/metadata.json
---
multiple graphql types found with the same name: App_Invoice

View File

@ -1 +0,0 @@
the following aggregate expression is defined more than once: Invoice_aggregate_exp (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/disallow_duplicate_name/metadata.json
---
the following aggregate expression is defined more than once: Invoice_aggregate_exp (in subgraph default)

View File

@ -1 +0,0 @@
an unnecessary filter input type name graphql configuration has been specified for model Invoice (in subgraph default) that does not use aggregates

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/disallow_model_filter_input_type_without_aggregate_expression/metadata.json
---
an unnecessary filter input type name graphql configuration has been specified for model Invoice (in subgraph default) that does not use aggregates

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/disallow_multiple_nested_array_agg/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) specifies an aggregatable field 'doubleNestedInt' of type [[Int4]] (in subgraph default), however arrays of arrays are not supported for aggregation

View File

@ -1 +0,0 @@
the aggregate expression Invoice_aggregate_exp (in subgraph default) has duplicate definitions of the aggregatable field 'invoiceId'

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/duplicated_aggregatable_fields/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) has duplicate definitions of the aggregatable field 'invoiceId'

View File

@ -1 +0,0 @@
the aggregate expression Int4_aggregate_exp (in subgraph default) has duplicate definitions of the aggregation function 'sum'

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/duplicated_aggregation_functions/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) has duplicate definitions of the aggregation function 'sum'

View File

@ -1 +0,0 @@
the aggregate expression Invoice_aggregate_exp (in subgraph default) used with model Invoice (in subgraph default) has not been defined

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_aggregate_exp_from_model/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) used with model Invoice (in subgraph default) has not been defined

View File

@ -1 +0,0 @@
the aggregate expression Invoice_aggregate_exp (in subgraph default) defines a graphql section and so query.aggregate must be set in the GraphqlConfig

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_aggregate_graphql_config/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) defines a graphql section and so query.aggregate must be set in the GraphqlConfig

View File

@ -1 +0,0 @@
the aggregate expression Int4_aggregate_exp (in subgraph default) defines an aggregation function mapping to an unknown data connector: mypg (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_aggregation_function_data_connector/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) defines an aggregation function mapping to an unknown data connector: mypg (in subgraph default)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_aggregation_function_data_connector_function/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_sum' which is mapped to the data connector 'mypg (in subgraph default)', however the mapped data connector aggregate function cannot be found: schum

View File

@ -1 +0,0 @@
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_min' but there is no mapping defined to an aggregation function in the data connector 'mypg (in subgraph default)'

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_aggregation_function_data_connector_mapping/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_min' but there is no mapping defined to an aggregation function in the data connector 'mypg (in subgraph default)'

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_aggregation_function_data_connector_operand_type/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_sum' but the mapping to the data connector 'mypg (in subgraph default)' specifies a data connector scalar type that does not exist: schmint

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_aggregation_function_mappings_to_model_data_connector/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) is used with the model Invoice (in subgraph default) but for the data connector mypg (in subgraph default) and scalar type int4, mappings are not provided for all aggregation functions in the aggregate expression

View File

@ -1 +0,0 @@
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function 'sum' that uses an unknown type for its return type: Int8

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_aggregation_function_return_type/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function 'sum' that uses an unknown type for its return type: Int8

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_data_connector_scalar_type_repr/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an aggregation function '_min' which is mapped to the data connector 'mypg (in subgraph default)' but the Open DD return type Int4! (in subgraph default) is not compatible with the data connector's return type. Reason: The data connector's return scalar type (int4) doesn't have a type representation

View File

@ -1 +0,0 @@
the filterInputFieldName for aggregate needs to be defined in GraphqlConfig, when models have a selectAggregate graphql API

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_filter_input_field_name_in_graphql_config/metadata.json
---
the filterInputFieldName for aggregate needs to be defined in GraphqlConfig, when models have a selectAggregate graphql API

View File

@ -1 +0,0 @@
filter input type name graphql configuration must be specified for model Invoice (in subgraph default) because it uses aggregates

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_model_filter_input_field_type/metadata.json
---
filter input type name graphql configuration must be specified for model Invoice (in subgraph default) because it uses aggregates

View File

@ -1 +0,0 @@
a source must be defined for model Invoice (in subgraph default) in order to use aggregate expressions

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_model_source/metadata.json
---
a source must be defined for model Invoice (in subgraph default) in order to use aggregate expressions

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_operand_object_field_agg_exp/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) specifies an aggregatable field 'invoiceId' that references an aggregate expression that cannot be found: Int4_aggregate_exp (in subgraph default)

View File

@ -1 +0,0 @@
the aggregate expression Invoice_aggregate_exp (in subgraph default) specifies an operand object type that cannot be found: Invoice (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_operand_object_type/metadata.json
---
the aggregate expression Invoice_aggregate_exp (in subgraph default) specifies an operand object type that cannot be found: Invoice (in subgraph default)

View File

@ -1 +0,0 @@
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an operand scalar type that cannot be found: Int4 (in subgraph default)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/missing_operand_scalar_type/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) specifies an operand scalar type that cannot be found: Int4 (in subgraph default)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/aggregate_expressions/model_aggregate_exp_type_mismatch/metadata.json
---
the aggregate expression Int4_aggregate_exp (in subgraph default) is used with the model Invoice (in subgraph default) but its operand type Int4 (in subgraph default) does not match the model's type Invoice (in subgraph default)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/boolean_expression/data_connector_not_found/metadata.json
---
data connector postgres_db (in subgraph __unknown_namespace) referenced in type mappings of type author (in subgraph __unknown_namespace) is not found in object type author (in subgraph __unknown_namespace)

View File

@ -1 +0,0 @@
unknown type used in object boolean expression: author (in subgraph __unknown_namespace)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/boolean_expression/missing_object_type/metadata.json
---
unknown type used in object boolean expression: author (in subgraph __unknown_namespace)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/boolean_expression/missing_scalar_type/metadata.json
---
could not find boolean expression type postgres_int_comparison_bool_exp (in subgraph __unknown_namespace) referenced within boolean expression author_bool_exp (in subgraph __unknown_namespace)

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/boolean_expression/nested_object_no_capability/metadata.json
---
The data connector custom (in subgraph __unknown_namespace) cannot be used for filtering nested object location_bool_exp (in subgraph __unknown_namespace) within institution_bool_exp (in subgraph __unknown_namespace) as it has not defined any capabilities for nested object filtering

View File

@ -1 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/boolean_expression/remote_relationship_not_allowed/metadata.json
---
Model Articles (in subgraph __unknown_namespace) has source data connector postgres_db_2 (in subgraph __unknown_namespace) but its filter expression type author_bool_exp (in subgraph __unknown_namespace) is backed by data connector postgres_db (in subgraph __unknown_namespace)

View File

@ -1 +0,0 @@
The field location has type location (in subgraph default) but the field's boolean expression type string_bool_exp (in subgraph default) has type String

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/boolean_expression/scalar_bool_exp_on_object_field/metadata.json
---
The field location has type location (in subgraph default) but the field's boolean expression type string_bool_exp (in subgraph default) has type String

View File

@ -1 +0,0 @@
field author_id is missing a mapping for data connector postgres_db (in subgraph __unknown_namespace) in boolean expression author_bool_exp (in subgraph __unknown_namespace)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/boolean_expression/scalars_not_defined_for_data_connector/metadata.json
---
field author_id is missing a mapping for data connector postgres_db (in subgraph __unknown_namespace) in boolean expression author_bool_exp (in subgraph __unknown_namespace)

View File

@ -1 +0,0 @@
cannot find scalar type Missing in data connector postgres_db (in subgraph __unknown_namespace)

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/boolean_expression/type_not_known_to_data_connector/metadata.json
---
cannot find scalar type Missing in data connector postgres_db (in subgraph __unknown_namespace)

View File

@ -1 +0,0 @@
NDC validation error: type foobar is not defined in the agent schema

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/command_no_ndc_function/metadata.json
---
NDC validation error: type foobar is not defined in the agent schema

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/simple/metadata.json
---
invalid type: not a sequence or map, expected a sequence or map at path $

View File

@ -1 +0,0 @@
invalid type: not a sequence or map, expected a sequence or map at path $

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/subgraph_invalid_name/metadata.json
---
__ is a reserved prefix for subgraph names at path $.subgraphs[0].name

View File

@ -1 +0,0 @@
__ is a reserved prefix for subgraph names at path $.subgraphs[0].name

View File

@ -1 +0,0 @@
graphql configuration should be defined only once in supergraph

View File

@ -0,0 +1,6 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: msg
input_file: crates/metadata-resolve/tests/failing/supergraph_too_many_graphql_configs/metadata.json
---
graphql configuration should be defined only once in supergraph

View File

@ -1,69 +1,77 @@
//! Tests that attempt to resolve different metadata files and assert that they parse successfully
//! or fail in the expected way.
use std::fs;
use std::path::PathBuf;
use metadata_resolve::MetadataResolveFlagsInternal;
#[test_each::file(
glob = "crates/metadata-resolve/tests/passing/**/metadata.json",
name(segments = 3)
)]
fn test_passing_metadata(metadata_json_text: &str) -> anyhow::Result<()> {
let metadata_resolve_flags_internal = MetadataResolveFlagsInternal {
enable_boolean_expression_types: true,
enable_aggregate_relationships: true,
};
let metadata_json_value = serde_json::from_str(metadata_json_text)?;
let metadata = open_dds::traits::OpenDd::deserialize(metadata_json_value)?;
let resolved = metadata_resolve::resolve(metadata, metadata_resolve_flags_internal);
match resolved {
Ok(_) => Ok(()),
Err(msg) => panic!("{msg}"),
}
}
#[test_each::file(
glob = "crates/metadata-resolve/tests/failing/**/metadata.json",
name(segments = 3)
)]
#[allow(clippy::needless_pass_by_value)] // must receive a `PathBuf`
fn test_failing_metadata(
metadata_json_text: &str,
metadata_json_path: PathBuf,
) -> anyhow::Result<()> {
let comparison_folder_path = metadata_json_path.parent().unwrap();
let failing_reason = comparison_folder_path.join("expected_error.txt");
let metadata_resolve_flags_internal = MetadataResolveFlagsInternal {
enable_boolean_expression_types: true,
enable_aggregate_relationships: true,
};
let error_untrimmed = fs::read_to_string(failing_reason)?;
let error = error_untrimmed.trim();
match serde_json::from_str(metadata_json_text) {
Ok(metadata_json_value) => {
match open_dds::traits::OpenDd::deserialize(metadata_json_value) {
Ok(metadata) => {
match metadata_resolve::resolve(metadata, metadata_resolve_flags_internal) {
Ok(_) => panic!("Expected to fail with {error}"),
Err(msg) => similar_asserts::assert_eq!(error, msg.to_string()),
}
}
Err(msg) => similar_asserts::assert_eq!(msg.to_string(), error),
#[test]
fn test_passing_metadata() {
insta::glob!("passing/**/metadata.json", |path| {
insta::with_settings!({
snapshot_path => path.parent().unwrap(),
snapshot_suffix => "",
prepend_module_to_snapshot => false,
}, {
let metadata_resolve_flags_internal = MetadataResolveFlagsInternal {
enable_boolean_expression_types: true,
enable_aggregate_relationships: true,
};
}
Err(msg) => {
similar_asserts::assert_eq!(msg.to_string(), error);
}
};
let metadata_json_text = std::fs::read_to_string(path)
.unwrap_or_else(|error| panic!("Could not read file {path:?}: {error}"));
Ok(())
let metadata_json_value = serde_json::from_str(&metadata_json_text)
.unwrap_or_else(|error| panic!("Could not parse JSON: {error}"));
let metadata = open_dds::traits::OpenDd::deserialize(metadata_json_value)
.unwrap_or_else(|error| panic!("Could not deserialize metadata: {error}"));
let resolved = metadata_resolve::resolve(metadata, metadata_resolve_flags_internal)
.unwrap_or_else(|error| panic!("Could not resolve metadata: {error}"));
insta::assert_debug_snapshot!("resolved", resolved);
});
});
}
#[test]
fn test_failing_metadata() {
insta::glob!("failing/**/metadata.json", |path| {
insta::with_settings!({
snapshot_path => path.parent().unwrap(),
snapshot_suffix => "",
prepend_module_to_snapshot => false,
}, {
let metadata_resolve_flags_internal = MetadataResolveFlagsInternal {
enable_boolean_expression_types: true,
enable_aggregate_relationships: true,
};
let metadata_json_text = std::fs::read_to_string(path)
.unwrap_or_else(|error| panic!("Could not read file {path:?}: {error}"));
match serde_json::from_str(&metadata_json_text) {
Ok(metadata_json_value) => {
match open_dds::traits::OpenDd::deserialize(metadata_json_value) {
Ok(metadata) => {
match metadata_resolve::resolve(metadata, metadata_resolve_flags_internal) {
Ok(_) => {
panic!("Unexpected success when resolving {path:?}.");
}
Err(msg) => {
insta::assert_snapshot!("resolve_error", msg);
}
}
}
Err(msg) => {
insta::assert_snapshot!("deserialize_error", msg);
}
};
}
Err(msg) => {
insta::assert_snapshot!("parse_error", msg);
}
};
});
});
}

View File

@ -0,0 +1,653 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: resolved
input_file: crates/metadata-resolve/tests/passing/boolean_expression_type/basic/metadata.json
---
Metadata {
object_types: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"author",
),
),
}: ObjectTypeWithRelationships {
object_type: ObjectTypeRepresentation {
fields: {
FieldName(
Identifier(
"author_id",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"first_name",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"last_name",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
},
global_id_fields: [],
apollo_federation_config: None,
graphql_output_type_name: Some(
TypeName(
Name(
"Author",
),
),
),
graphql_input_type_name: None,
description: None,
},
type_output_permissions: {
Role(
"admin",
): TypeOutputPermission {
allowed_fields: {
FieldName(
Identifier(
"author_id",
),
),
FieldName(
Identifier(
"first_name",
),
),
FieldName(
Identifier(
"last_name",
),
),
},
},
Role(
"user_1",
): TypeOutputPermission {
allowed_fields: {
FieldName(
Identifier(
"author_id",
),
),
FieldName(
Identifier(
"first_name",
),
),
FieldName(
Identifier(
"last_name",
),
),
},
},
},
type_input_permissions: {},
relationship_fields: {},
type_mappings: DataConnectorTypeMappingsForObject(
{
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: {
DataConnectorObjectType(
"author",
): Object {
ndc_object_type_name: DataConnectorObjectType(
"author",
),
field_mappings: {
FieldName(
Identifier(
"author_id",
),
): FieldMapping {
column: DataConnectorColumnName(
"id",
),
column_type: Named {
name: "int4",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"first_name",
),
): FieldMapping {
column: DataConnectorColumnName(
"first_name",
),
column_type: Named {
name: "String",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"last_name",
),
): FieldMapping {
column: DataConnectorColumnName(
"last_name",
),
column_type: Named {
name: "String",
},
column_type_representation: None,
argument_mappings: {},
},
},
},
},
},
),
},
},
scalar_types: {},
models: {},
commands: {},
object_boolean_expression_types: {},
boolean_expression_types: BooleanExpressionTypes {
objects: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"author_bool_exp",
),
),
}: ResolvedObjectBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"author_bool_exp",
),
),
},
object_type: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"author",
),
),
},
graphql: Some(
BooleanExpressionGraphqlConfig {
type_name: TypeName(
Name(
"AuthorBoolExp",
),
),
object_fields: {},
scalar_fields: {
FieldName(
Identifier(
"author_id",
),
): ComparisonExpressionInfo {
object_type_name: Some(
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_int_comparison_bool_exp",
),
),
},
),
type_name: TypeName(
Name(
"PostgresIntBoolExp",
),
),
operators: {
OperatorName(
"_in",
): QualifiedTypeReference {
underlying_type: List(
QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
),
nullable: false,
},
OperatorName(
"equals",
): QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
},
operator_mapping: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: {
OperatorName(
"equals",
): DataConnectorOperatorName(
"_eq",
),
},
},
is_null_operator_name: Some(
Name(
"_is_null",
),
),
},
FieldName(
Identifier(
"first_name",
),
): ComparisonExpressionInfo {
object_type_name: Some(
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_string_comparison_bool_exp",
),
),
},
),
type_name: TypeName(
Name(
"PostgresStringBoolExp",
),
),
operators: {
OperatorName(
"_in",
): QualifiedTypeReference {
underlying_type: List(
QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
),
nullable: false,
},
OperatorName(
"equals",
): QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
},
operator_mapping: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: {
OperatorName(
"equals",
): DataConnectorOperatorName(
"_eq",
),
},
},
is_null_operator_name: Some(
Name(
"_is_null",
),
),
},
FieldName(
Identifier(
"last_name",
),
): ComparisonExpressionInfo {
object_type_name: Some(
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_string_comparison_bool_exp",
),
),
},
),
type_name: TypeName(
Name(
"PostgresStringBoolExp",
),
),
operators: {
OperatorName(
"_in",
): QualifiedTypeReference {
underlying_type: List(
QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
),
nullable: false,
},
OperatorName(
"equals",
): QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
},
operator_mapping: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: {
OperatorName(
"equals",
): DataConnectorOperatorName(
"_eq",
),
},
},
is_null_operator_name: Some(
Name(
"_is_null",
),
),
},
},
relationship_fields: {},
graphql_config: BooleanExpressionGraphqlFieldConfig {
where_field_name: Name(
"where",
),
and_operator_name: Name(
"_and",
),
or_operator_name: Name(
"_or",
),
not_operator_name: Name(
"_not",
),
},
},
),
include_logical_operators: Yes,
},
},
scalars: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_int_comparison_bool_exp",
),
),
}: ResolvedScalarBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_int_comparison_bool_exp",
),
),
},
comparison_operators: {
OperatorName(
"_in",
): TypeReference {
underlying_type: List(
TypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
),
nullable: false,
},
OperatorName(
"equals",
): TypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
},
data_connector_operator_mappings: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: DataConnectorOperatorMapping {
data_connector_name: DataConnectorName(
Identifier(
"postgres_db",
),
),
data_connector_scalar_type: DataConnectorScalarType(
"int8",
),
operator_mapping: {
OperatorName(
"equals",
): DataConnectorOperatorName(
"_eq",
),
},
},
},
graphql_name: Some(
GraphQlTypeName(
"PostgresIntBoolExp",
),
),
include_is_null: Yes,
},
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_string_comparison_bool_exp",
),
),
}: ResolvedScalarBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_string_comparison_bool_exp",
),
),
},
comparison_operators: {
OperatorName(
"_in",
): TypeReference {
underlying_type: List(
TypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
),
nullable: false,
},
OperatorName(
"equals",
): TypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
},
data_connector_operator_mappings: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: DataConnectorOperatorMapping {
data_connector_name: DataConnectorName(
Identifier(
"postgres_db",
),
),
data_connector_scalar_type: DataConnectorScalarType(
"String",
),
operator_mapping: {
OperatorName(
"equals",
): DataConnectorOperatorName(
"_eq",
),
},
},
},
graphql_name: Some(
GraphQlTypeName(
"PostgresStringBoolExp",
),
),
include_is_null: Yes,
},
},
},
aggregate_expressions: {},
graphql_config: GlobalGraphqlConfig {
query_root_type_name: TypeName(
Name(
"Query",
),
),
mutation_root_type_name: TypeName(
Name(
"Mutation",
),
),
order_by_input: Some(
OrderByInputGraphqlConfig {
asc_direction_field_value: Name(
"Asc",
),
desc_direction_field_value: Name(
"Desc",
),
enum_type_name: TypeName(
Name(
"order_by",
),
),
},
),
enable_apollo_federation_fields: false,
},
roles: [
Role(
"admin",
),
Role(
"user_1",
),
],
}

View File

@ -0,0 +1,412 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: resolved
input_file: crates/metadata-resolve/tests/passing/boolean_expression_type/no_graphql/metadata.json
---
Metadata {
object_types: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"author",
),
),
}: ObjectTypeWithRelationships {
object_type: ObjectTypeRepresentation {
fields: {
FieldName(
Identifier(
"author_id",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"first_name",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"last_name",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
},
global_id_fields: [],
apollo_federation_config: None,
graphql_output_type_name: Some(
TypeName(
Name(
"Author",
),
),
),
graphql_input_type_name: None,
description: None,
},
type_output_permissions: {
Role(
"admin",
): TypeOutputPermission {
allowed_fields: {
FieldName(
Identifier(
"author_id",
),
),
FieldName(
Identifier(
"first_name",
),
),
FieldName(
Identifier(
"last_name",
),
),
},
},
Role(
"user_1",
): TypeOutputPermission {
allowed_fields: {
FieldName(
Identifier(
"author_id",
),
),
FieldName(
Identifier(
"first_name",
),
),
FieldName(
Identifier(
"last_name",
),
),
},
},
},
type_input_permissions: {},
relationship_fields: {},
type_mappings: DataConnectorTypeMappingsForObject(
{
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: {
DataConnectorObjectType(
"author",
): Object {
ndc_object_type_name: DataConnectorObjectType(
"author",
),
field_mappings: {
FieldName(
Identifier(
"author_id",
),
): FieldMapping {
column: DataConnectorColumnName(
"id",
),
column_type: Named {
name: "int4",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"first_name",
),
): FieldMapping {
column: DataConnectorColumnName(
"first_name",
),
column_type: Named {
name: "String",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"last_name",
),
): FieldMapping {
column: DataConnectorColumnName(
"last_name",
),
column_type: Named {
name: "String",
},
column_type_representation: None,
argument_mappings: {},
},
},
},
},
},
),
},
},
scalar_types: {},
models: {},
commands: {},
object_boolean_expression_types: {},
boolean_expression_types: BooleanExpressionTypes {
objects: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"author_bool_exp",
),
),
}: ResolvedObjectBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"author_bool_exp",
),
),
},
object_type: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"author",
),
),
},
graphql: None,
include_logical_operators: Yes,
},
},
scalars: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_int_comparison_bool_exp",
),
),
}: ResolvedScalarBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_int_comparison_bool_exp",
),
),
},
comparison_operators: {
OperatorName(
"_in",
): TypeReference {
underlying_type: List(
TypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
),
nullable: false,
},
OperatorName(
"equals",
): TypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
},
data_connector_operator_mappings: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: DataConnectorOperatorMapping {
data_connector_name: DataConnectorName(
Identifier(
"postgres_db",
),
),
data_connector_scalar_type: DataConnectorScalarType(
"int8",
),
operator_mapping: {
OperatorName(
"equals",
): DataConnectorOperatorName(
"_eq",
),
},
},
},
graphql_name: None,
include_is_null: Yes,
},
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_string_comparison_bool_exp",
),
),
}: ResolvedScalarBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"postgres_string_comparison_bool_exp",
),
),
},
comparison_operators: {
OperatorName(
"_in",
): TypeReference {
underlying_type: List(
TypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
),
nullable: false,
},
OperatorName(
"equals",
): TypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
},
data_connector_operator_mappings: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"postgres_db",
),
),
}: DataConnectorOperatorMapping {
data_connector_name: DataConnectorName(
Identifier(
"postgres_db",
),
),
data_connector_scalar_type: DataConnectorScalarType(
"String",
),
operator_mapping: {
OperatorName(
"equals",
): DataConnectorOperatorName(
"_eq",
),
},
},
},
graphql_name: None,
include_is_null: Yes,
},
},
},
aggregate_expressions: {},
graphql_config: GlobalGraphqlConfig {
query_root_type_name: TypeName(
Name(
"Query",
),
),
mutation_root_type_name: TypeName(
Name(
"Mutation",
),
),
order_by_input: Some(
OrderByInputGraphqlConfig {
asc_direction_field_value: Name(
"Asc",
),
desc_direction_field_value: Name(
"Desc",
),
enum_type_name: TypeName(
Name(
"order_by",
),
),
},
),
enable_apollo_federation_fields: false,
},
roles: [
Role(
"admin",
),
Role(
"user_1",
),
],
}

View File

@ -0,0 +1,921 @@
---
source: crates/metadata-resolve/tests/metadata_golden_tests.rs
expression: resolved
input_file: crates/metadata-resolve/tests/passing/boolean_expression_type/range/metadata.json
---
Metadata {
object_types: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"int_range",
),
),
}: ObjectTypeWithRelationships {
object_type: ObjectTypeRepresentation {
fields: {
FieldName(
Identifier(
"start",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"end",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
},
global_id_fields: [],
apollo_federation_config: None,
graphql_output_type_name: Some(
TypeName(
Name(
"IntRange",
),
),
),
graphql_input_type_name: None,
description: None,
},
type_output_permissions: {},
type_input_permissions: {},
relationship_fields: {},
type_mappings: DataConnectorTypeMappingsForObject(
{
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"custom",
),
),
}: {
DataConnectorObjectType(
"int_range",
): Object {
ndc_object_type_name: DataConnectorObjectType(
"int_range",
),
field_mappings: {
FieldName(
Identifier(
"end",
),
): FieldMapping {
column: DataConnectorColumnName(
"lte",
),
column_type: Named {
name: "Int",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"start",
),
): FieldMapping {
column: DataConnectorColumnName(
"gte",
),
column_type: Named {
name: "Int",
},
column_type_representation: None,
argument_mappings: {},
},
},
},
},
},
),
},
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"movie",
),
),
}: ObjectTypeWithRelationships {
object_type: ObjectTypeRepresentation {
fields: {
FieldName(
Identifier(
"id",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"title",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"rating",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
},
global_id_fields: [],
apollo_federation_config: None,
graphql_output_type_name: Some(
TypeName(
Name(
"Movie",
),
),
),
graphql_input_type_name: None,
description: None,
},
type_output_permissions: {
Role(
"admin",
): TypeOutputPermission {
allowed_fields: {
FieldName(
Identifier(
"id",
),
),
FieldName(
Identifier(
"title",
),
),
FieldName(
Identifier(
"rating",
),
),
},
},
},
type_input_permissions: {},
relationship_fields: {},
type_mappings: DataConnectorTypeMappingsForObject(
{
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"custom",
),
),
}: {
DataConnectorObjectType(
"movie",
): Object {
ndc_object_type_name: DataConnectorObjectType(
"movie",
),
field_mappings: {
FieldName(
Identifier(
"id",
),
): FieldMapping {
column: DataConnectorColumnName(
"id",
),
column_type: Named {
name: "Int",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"rating",
),
): FieldMapping {
column: DataConnectorColumnName(
"rating",
),
column_type: Named {
name: "Int",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"title",
),
): FieldMapping {
column: DataConnectorColumnName(
"title",
),
column_type: Named {
name: "String",
},
column_type_representation: None,
argument_mappings: {},
},
},
},
},
},
),
},
},
scalar_types: {},
models: {
Qualified {
subgraph: "__unknown_namespace",
name: ModelName(
Identifier(
"movies",
),
),
}: ModelWithPermissions {
model: Model {
name: Qualified {
subgraph: "__unknown_namespace",
name: ModelName(
Identifier(
"movies",
),
),
},
data_type: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"movie",
),
),
},
type_fields: {
FieldName(
Identifier(
"id",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"title",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
String,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
FieldName(
Identifier(
"rating",
),
): FieldDefinition {
field_type: QualifiedTypeReference {
underlying_type: Named(
Inbuilt(
Int,
),
),
nullable: false,
},
description: None,
deprecated: None,
field_arguments: {},
},
},
global_id_fields: [],
arguments: {},
source: Some(
ModelSource {
data_connector: DataConnectorLink {
name: Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"custom",
),
),
},
url: SingleUrl(
SerializableUrl(
Url {
scheme: "http",
cannot_be_a_base: false,
username: "",
password: None,
host: Some(
Domain(
"custom_connector",
),
),
port: Some(
8101,
),
path: "/",
query: None,
fragment: None,
},
),
),
headers: SerializableHeaderMap(
{},
),
argument_presets: [],
response_config: None,
capabilities: DataConnectorCapabilities {
supports_explaining_queries: true,
supports_explaining_mutations: false,
supports_nested_object_filtering: true,
supports_nested_object_aggregations: false,
},
},
collection: "movies",
collection_type: DataConnectorObjectType(
"movie",
),
type_mappings: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"movie",
),
),
}: Object {
ndc_object_type_name: DataConnectorObjectType(
"movie",
),
field_mappings: {
FieldName(
Identifier(
"id",
),
): FieldMapping {
column: DataConnectorColumnName(
"id",
),
column_type: Named {
name: "Int",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"rating",
),
): FieldMapping {
column: DataConnectorColumnName(
"rating",
),
column_type: Named {
name: "Int",
},
column_type_representation: None,
argument_mappings: {},
},
FieldName(
Identifier(
"title",
),
): FieldMapping {
column: DataConnectorColumnName(
"title",
),
column_type: Named {
name: "String",
},
column_type_representation: None,
argument_mappings: {},
},
},
},
},
argument_mappings: {},
source_arguments: {},
},
),
global_id_source: None,
apollo_federation_key_source: None,
orderable_fields: [
OrderableField {
field_name: FieldName(
Identifier(
"id",
),
),
order_by_directions: EnableAll(
true,
),
},
OrderableField {
field_name: FieldName(
Identifier(
"title",
),
),
order_by_directions: EnableAll(
true,
),
},
OrderableField {
field_name: FieldName(
Identifier(
"rating",
),
),
order_by_directions: EnableAll(
true,
),
},
],
aggregate_expression: None,
raw: ModelRaw {
filter_expression_type: None,
graphql: Some(
ModelGraphQlDefinition {
select_uniques: [],
select_many: Some(
SelectManyGraphQlDefinition {
query_root_field: GraphQlFieldName(
"MovieMany",
),
description: None,
deprecated: None,
},
),
arguments_input_type: None,
order_by_expression_type: None,
apollo_federation: None,
filter_input_type_name: None,
aggregate: None,
},
),
description: None,
},
},
select_permissions: {
Role(
"admin",
): SelectPermission {
filter: AllowAll,
argument_presets: {},
},
},
filter_expression_type: None,
graphql_api: ModelGraphQlApi {
arguments_input_config: None,
select_uniques: [],
select_many: Some(
SelectManyGraphQlDefinition {
query_root_field: Name(
"MovieMany",
),
description: None,
deprecated: None,
},
),
select_aggregate: None,
order_by_expression: None,
limit_field: Some(
LimitFieldGraphqlConfig {
field_name: Name(
"limit",
),
},
),
offset_field: Some(
OffsetFieldGraphqlConfig {
field_name: Name(
"offset",
),
},
),
filter_input_type_name: None,
},
},
},
commands: {},
object_boolean_expression_types: {},
boolean_expression_types: BooleanExpressionTypes {
objects: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"movie_bool_exp",
),
),
}: ResolvedObjectBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"movie_bool_exp",
),
),
},
object_type: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"movie",
),
),
},
graphql: Some(
BooleanExpressionGraphqlConfig {
type_name: TypeName(
Name(
"InstitutionBoolExp",
),
),
object_fields: {},
scalar_fields: {
FieldName(
Identifier(
"rating",
),
): ComparisonExpressionInfo {
object_type_name: Some(
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"int_range_bool_exp",
),
),
},
),
type_name: TypeName(
Name(
"Int_Comparison_Exp",
),
),
operators: {
OperatorName(
"within",
): QualifiedTypeReference {
underlying_type: Named(
Custom(
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"int_range",
),
),
},
),
),
nullable: true,
},
},
operator_mapping: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"custom",
),
),
}: {
OperatorName(
"within",
): DataConnectorOperatorName(
"range",
),
},
},
is_null_operator_name: Some(
Name(
"_is_null",
),
),
},
FieldName(
Identifier(
"title",
),
): ComparisonExpressionInfo {
object_type_name: Some(
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"string_bool_exp",
),
),
},
),
type_name: TypeName(
Name(
"String_Comparison_Exp",
),
),
operators: {},
operator_mapping: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"custom",
),
),
}: {},
},
is_null_operator_name: Some(
Name(
"_is_null",
),
),
},
},
relationship_fields: {},
graphql_config: BooleanExpressionGraphqlFieldConfig {
where_field_name: Name(
"where",
),
and_operator_name: Name(
"_and",
),
or_operator_name: Name(
"_or",
),
not_operator_name: Name(
"_not",
),
},
},
),
include_logical_operators: Yes,
},
},
scalars: {
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"int_bool_exp",
),
),
}: ResolvedScalarBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"int_bool_exp",
),
),
},
comparison_operators: {},
data_connector_operator_mappings: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"custom",
),
),
}: DataConnectorOperatorMapping {
data_connector_name: DataConnectorName(
Identifier(
"custom",
),
),
data_connector_scalar_type: DataConnectorScalarType(
"Int",
),
operator_mapping: {},
},
},
graphql_name: None,
include_is_null: Yes,
},
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"int_range_bool_exp",
),
),
}: ResolvedScalarBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"int_range_bool_exp",
),
),
},
comparison_operators: {
OperatorName(
"within",
): TypeReference {
underlying_type: Named(
Custom(
CustomTypeName(
Identifier(
"int_range",
),
),
),
),
nullable: true,
},
},
data_connector_operator_mappings: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"custom",
),
),
}: DataConnectorOperatorMapping {
data_connector_name: DataConnectorName(
Identifier(
"custom",
),
),
data_connector_scalar_type: DataConnectorScalarType(
"Int",
),
operator_mapping: {
OperatorName(
"within",
): DataConnectorOperatorName(
"range",
),
},
},
},
graphql_name: Some(
GraphQlTypeName(
"Int_Comparison_Exp",
),
),
include_is_null: Yes,
},
Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"string_bool_exp",
),
),
}: ResolvedScalarBooleanExpressionType {
name: Qualified {
subgraph: "__unknown_namespace",
name: CustomTypeName(
Identifier(
"string_bool_exp",
),
),
},
comparison_operators: {},
data_connector_operator_mappings: {
Qualified {
subgraph: "__unknown_namespace",
name: DataConnectorName(
Identifier(
"custom",
),
),
}: DataConnectorOperatorMapping {
data_connector_name: DataConnectorName(
Identifier(
"custom",
),
),
data_connector_scalar_type: DataConnectorScalarType(
"String",
),
operator_mapping: {},
},
},
graphql_name: Some(
GraphQlTypeName(
"String_Comparison_Exp",
),
),
include_is_null: Yes,
},
},
},
aggregate_expressions: {},
graphql_config: GlobalGraphqlConfig {
query_root_type_name: TypeName(
Name(
"Query",
),
),
mutation_root_type_name: TypeName(
Name(
"Mutation",
),
),
order_by_input: Some(
OrderByInputGraphqlConfig {
asc_direction_field_value: Name(
"Asc",
),
desc_direction_field_value: Name(
"Desc",
),
enum_type_name: TypeName(
Name(
"order_by",
),
),
},
),
enable_apollo_federation_fields: false,
},
roles: [
Role(
"admin",
),
Role(
"admin",
),
],
}

Some files were not shown because too many files have changed in this diff Show More