Skip to content

Feature/handle multiple connection strings and list filters - #3187

Open
anthomaxcool wants to merge 9 commits into
Azure:mainfrom
anthomaxcool:feature/handle-multiple-connection-strings-and-list-filters
Open

Feature/handle multiple connection strings and list filters#3187
anthomaxcool wants to merge 9 commits into
Azure:mainfrom
anthomaxcool:feature/handle-multiple-connection-strings-and-list-filters

Conversation

@anthomaxcool

Copy link
Copy Markdown

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-files in dab-config.json and allows list filtering.

How was this tested?

  • Unit Tests

Sample Request(s)

{
    planets(filter : {tags: { some: { contains : ""tag""}}})
    {
        items {
            id
            name
        }
    }
}

@anthomaxcool

Copy link
Copy Markdown
Author

@anthomaxcool please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@JerryNixon JerryNixon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anthomaxcool

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.

@Aniruddh25 Aniruddh25 removed the 2.0 label Mar 12, 2026
@anthomaxcool
anthomaxcool force-pushed the feature/handle-multiple-connection-strings-and-list-filters branch from f9a2fb0 to 3aa1a6b Compare June 29, 2026 13:46
Copilot AI review requested due to automatic review settings June 29, 2026 13:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 @model types 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.

Comment thread Dockerfile Outdated
Comment thread src/Core/Models/GraphQLFilterParsers.cs Outdated
Comment thread src/Core/Models/GraphQLFilterParsers.cs Outdated
Comment thread src/Core/Models/GraphQLFilterParsers.cs Outdated
Comment thread src/Core/Resolvers/CosmosQueryEngine.cs Outdated
Comment thread src/Core/Services/GraphQLSchemaCreator.cs
Comment thread src/Core/Services/GraphQLSchemaCreator.cs Outdated
Comment thread src/Service.Tests/CosmosTests/QueryFilterTests.cs
@anthomaxcool
anthomaxcool force-pushed the feature/handle-multiple-connection-strings-and-list-filters branch from 3aa1a6b to ba458af Compare June 29, 2026 14:31
@anthomaxcool
anthomaxcool requested a review from JerryNixon June 29, 2026 17:09
@anthomaxcool

Copy link
Copy Markdown
Author

@JerryNixon Thanks for the review and sorry for the wait, Here is a corrected version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: An item with the same key has already been added. Cosmos DB using two config files

5 participants