Feature/handle multiple connection strings and list filters - #3187
Feature/handle multiple connection strings and list filters#3187anthomaxcool wants to merge 9 commits into
Conversation
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
1. In parser:
- any: true => ARRAY_ANY -> SQL ARRAY_LENGTH(field) > 0
- any: false => coerced to IS NULL
That makes “no elements” equivalent to “is null”, but empty array is not null. Expected
semantics for any: false are usually “array is null OR length == 0” (depending on product definition). This currently only checks null. If intended behavior is “not non-empty”, this is a bug.
2. CosmosQueryBuilder builds nested predicate text and then Replace(arrayField, elementAlias).
This is fragile when:
- field string appears in literals or function args
- nested structures include same token as substring
- multiple levels of nesting reuse similar field names
Safer would be AST-aware rendering with scoped symbol binding, not text replacement.
3. Build(PredicateOperation op) returns tokens not used as SQL operators
You added:
- ARRAY_SOME, ARRAY_NONE, ARRAY_ALL, ARRAY_ANY
But actual SQL emitted for these is custom branches in Build(Predicate?). Returning string constants here may be misleading and could accidentally leak if future code paths call Build(op) directly.
4. GraphQLSchemaCreator now dedups by INamedSyntaxNode.Name.Value across datasource roots.
If two sources define same type name differently, second definition is silently dropped. This may:
- mask config errors
- produce surprising schema depending on iteration order
You should likely detect conflict and throw explicit validation error on differing shapes.
5. Silent continue in Query/Mutation builders can hide config/schema mismatch
Skipping object types not in entities avoids crashes, but silently drops fields/types.
Good for robustness, but this should at least log diagnostic warnings; otherwise users may get “missing operations” with no clue why.
6. CreateListFilter adds legacy operators (contains, startsWith, endsWith) for every scalar list type via elementScalarType.
For non-string scalars these operators are semantically odd/unusable unless downstream validates/rejects later.
Could be intentional for backward compatibility, but deserves explicit gating or tests confirming behavior by scalar type.
f9a2fb0 to
3aa1a6b
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses Cosmos DB NoSQL multi–data-source GraphQL schema generation issues (notably duplicate input-type key collisions) and adds support for list filtering operators (some/none/all/any) in GraphQL filters, aligning behavior with HotChocolate list-filter semantics.
Changes:
- Scope Cosmos metadata loading to a specific data source name and update call sites accordingly.
- Add list filter input types + parsing + Cosmos SQL query generation for list quantifiers (
some/none/all/any). - Improve Cosmos schema generation for multi data sources by merging schema definitions and skipping non-entity
@modeltypes during query/mutation generation.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service.Tests/CosmosTests/TestBase.cs | Updates Cosmos metadata provider construction to pass a data source name. |
| src/Service.Tests/CosmosTests/QueryFilterTests.cs | Adds Cosmos list-filter query tests for some/none/all/any. |
| src/Service.Tests/Configuration/ConfigurationTests.cs | Updates metadata provider construction in schema validation tests. |
| src/Service.GraphQLBuilder/Queries/StandardQueryInputs.cs | Introduces standard list-filter input types (*ListFilterInput). |
| src/Service.GraphQLBuilder/Queries/QueryBuilder.cs | Skips generating queries for Cosmos @model types not present as runtime entities. |
| src/Service.GraphQLBuilder/Queries/InputTypeBuilder.cs | Generates list-filter input bindings for list-typed scalar fields; avoids duplicate input-type key errors. |
| src/Service.GraphQLBuilder/Mutations/MutationBuilder.cs | Skips generating mutations for Cosmos @model types not present as runtime entities. |
| src/Directory.Packages.props | Updates OpenTelemetry package versions. |
| src/Core/Services/MetadataProviders/MetadataProviderFactory.cs | Passes the current data source name into the Cosmos metadata provider. |
| src/Core/Services/MetadataProviders/CosmosSqlMetadataProvider.cs | Uses the specified data source rather than always the default data source. |
| src/Core/Services/GraphQLSchemaCreator.cs | Merges Cosmos schema definitions across data sources; grafts configured relationship fields onto Cosmos types. |
| src/Core/Resolvers/CosmosQueryStructure.cs | Ensures relationship source fields are selected for relationship resolution. |
| src/Core/Resolvers/CosmosQueryEngine.cs | Adds relationship resolution via cross-container queries and relationship-field filter handling. |
| src/Core/Resolvers/CosmosQueryBuilder.cs | Adds Cosmos SQL generation for list quantifiers and IN. |
| src/Core/Models/SqlQueryStructures.cs | Extends predicate ops with ARRAY_SOME/ARRAY_NONE/ARRAY_ALL/ARRAY_ANY. |
| src/Core/Models/GraphQLFilterParsers.cs | Parses list quantifier filters into the new array predicate operations. |
| Dockerfile | Attempts to package dab-config*.json and *.gql into the runtime image. |
3aa1a6b to
ba458af
Compare
…ontainer relationships
|
@JerryNixon Thanks for the review and sorry for the wait, Here is a corrected version. |
Why make this change?
There's currently a bug that makes the use of multiple sources with nosql cosmos database impossible. This closes #2437
Also added list filters based on the HotChocolate documentation.
What is this change?
Fix
data-source-filesin dab-config.json and allows list filtering.How was this tested?
Sample Request(s)