Fix GraphQL aggregation features disabled when runtime.graphql config section is absent - #3450
Merged
Aniruddh Munde (Aniruddh25) merged 8 commits intoApr 30, 2026
Conversation
…n is absent - Fix RuntimeConfig.EnableAggregation to use consistent OR logic (returns true when Runtime is null or Runtime.GraphQL is null, matching IsGraphQLEnabled pattern) - Fix GraphQLSchemaCreator.OnConfigChanged to update _isAggregationEnabled on hot-reload - Add enable-aggregation to dab.draft.schema.json (runtime.graphql section) - Add unit tests: EnableAggregation defaults to true when graphql/runtime section absent, can be explicitly disabled; QueryBuilder adds groupBy to MSSQL connection type but not PostgreSQL Agent-Logs-Url: https://github.com/Azure/data-api-builder/sessions/b4c70fb5-8795-4c8a-a904-d54344395c93 Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
…BuilderTests Agent-Logs-Url: https://github.com/Azure/data-api-builder/sessions/b4c70fb5-8795-4c8a-a904-d54344395c93 Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix missing GraphQL aggregation features in DAB 2.0.0-rc schema
Fix GraphQL aggregation features disabled when runtime.graphql config section is absent
Apr 15, 2026
Aniruddh Munde (Aniruddh25)
marked this pull request as ready for review
April 22, 2026 23:07
Copilot started reviewing on behalf of
Aniruddh Munde (Aniruddh25)
April 22, 2026 23:08
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression where GraphQL aggregation features were incorrectly disabled when the runtime.graphql config section was omitted, despite aggregation defaulting to enabled.
Changes:
- Corrected
RuntimeConfig.EnableAggregationdefaulting behavior to treat missingruntime/runtime.graphqlas “enabled”. - Updated
GraphQLSchemaCreatorhot-reload handling to refresh the aggregation-enabled flag. - Extended
dab.draft.schema.jsonto allowruntime.graphql.enable-aggregation, and added unit tests covering defaults and schema surface area (groupBy presence).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service.Tests/GraphQLBuilder/QueryBuilderTests.cs | Adds unit tests verifying groupBy is present/absent based on aggregation enablement and supported DB types. |
| src/Service.Tests/Configuration/RuntimeConfigLoaderTests.cs | Adds unit tests validating EnableAggregation defaults and honoring explicit enable-aggregation. |
| src/Core/Services/GraphQLSchemaCreator.cs | Updates hot-reload path to refresh _isAggregationEnabled from latest runtime config. |
| src/Config/ObjectModel/RuntimeConfig.cs | Fixes EnableAggregation logic to default to true when config sections are absent; updates doc comment accordingly. |
| schemas/dab.draft.schema.json | Adds runtime.graphql.enable-aggregation to schema properties so configs can validate when explicitly set. |
Aniruddh Munde (Aniruddh25)
approved these changes
Apr 23, 2026
Anusha Kolan (anushakolan)
approved these changes
Apr 27, 2026
Anusha Kolan (anushakolan)
left a comment
Contributor
There was a problem hiding this comment.
The PR needs refactoring to reduce unnecessary repetition. Apart from this looks good.
…rized tests - Add LoadConfig helper in RuntimeConfigLoaderTests to eliminate repeated mock filesystem setup - Merge EnableAggregation_WhenExplicitlyDisabled/Enabled into a single DataTestMethod with DataRow(true) and DataRow(false) - Merge Build_WithMssql/PostgreSqlAndAggregationEnabled into a single DataTestMethod covering MSSQL, DWSQL, PostgreSQL, and MySQL Agent-Logs-Url: https://github.com/Azure/data-api-builder/sessions/7c3dcc98-f816-4bc1-b5cd-2228bf05e5cb Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
Anusha Kolan (anushakolan)
approved these changes
Apr 28, 2026
Aniruddh Munde (Aniruddh25)
deleted the
copilot/fix-graphql-aggregation-features
branch
April 30, 2026 22:42
naxing123
pushed a commit
that referenced
this pull request
Aug 12, 2026
… section is absent (#3450) ## Why make this change? GraphQL aggregation features (`groupBy`, `sum`, `avg`, `min`, `max`, `count`) were silently disabled for users whose config lacked an explicit `runtime.graphql` section, even though `EnableAggregation` defaults to `true`. ## What is this change? **Bug fix: `RuntimeConfig.EnableAggregation` logic inversion** The property used `&&` logic, returning `false` when `Runtime` or `Runtime.GraphQL` was `null`. This is inconsistent with every analogous property (e.g. `IsGraphQLEnabled`) which use `||` logic to treat absence as "use default (enabled)": ```csharp // Before (broken): returns false when runtime.graphql section is absent public bool EnableAggregation => Runtime is not null && Runtime.GraphQL is not null && Runtime.GraphQL.EnableAggregation; // After (fixed): returns true when section is absent, consistent with IsGraphQLEnabled public bool EnableAggregation => Runtime is null || Runtime.GraphQL is null || Runtime.GraphQL.EnableAggregation; ``` **Additional fixes:** - `GraphQLSchemaCreator.OnConfigChanged` now updates `_isAggregationEnabled` on hot-reload (was omitted, causing stale state) - `schemas/dab.draft.schema.json`: added `enable-aggregation` to `runtime.graphql` properties — it was missing despite `additionalProperties: false`, meaning any config explicitly setting the flag would fail schema validation **Test refactoring (per code review feedback):** - Extracted a `LoadConfig` private helper in `RuntimeConfigLoaderTests` to eliminate repeated mock-filesystem setup across all `EnableAggregation` tests - Merged `EnableAggregation_WhenExplicitlyDisabled_ReturnsFalse` and `EnableAggregation_WhenExplicitlyEnabled_ReturnsTrue` into a single parameterized `[DataTestMethod]` (`EnableAggregation_WhenExplicitlySet_ReturnsConfiguredValue`) using `[DataRow(true)]` and `[DataRow(false)]` - Merged `Build_WithMssqlAndAggregationEnabled_AddsGroupByToConnectionType` and `Build_WithPostgreSqlAndAggregationEnabled_DoesNotAddGroupByToConnectionType` into a single parameterized `[DataTestMethod]` (`Build_WithAggregationEnabled_GroupByPresenceMatchesDatabaseSupport`) covering MSSQL, DWSQL (groupBy present), PostgreSQL, and MySQL (groupBy absent) ## How was this tested? - [ ] Integration Tests - [x] Unit Tests - `RuntimeConfigLoaderTests`: `EnableAggregation` defaults to `true` when `runtime` or `runtime.graphql` sections are absent; a single parameterized test (`EnableAggregation_WhenExplicitlySet_ReturnsConfiguredValue`) covers both `true` and `false` explicit values using `[DataRow]`. A shared `LoadConfig` helper eliminates repeated mock-filesystem setup. - `QueryBuilderTests`: a single parameterized test (`Build_WithAggregationEnabled_GroupByPresenceMatchesDatabaseSupport`) covers MSSQL and DWSQL (groupBy present) and PostgreSQL and MySQL (groupBy absent), plus a test confirming groupBy is omitted when aggregation is disabled. ## Sample Request(s) With a config that has no explicit `runtime.graphql` section, the following now works as expected for MSSQL/DWSQL entities: ```graphql { books { groupBy(fields: [price]) { fields { price } aggregations { count sum(field: price) avg(field: price) max(field: price) min(field: price) } } } } ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com> Co-authored-by: Aniruddh Munde <anmunde@microsoft.com> Co-authored-by: Souvik Ghosh <souvikofficial04@gmail.com> (cherry picked from commit 9391685)
naxing123
added a commit
that referenced
this pull request
Aug 12, 2026
…ease/2.0 (#3767) Ports the PostgreSQL GraphQL groupby/aggregation and related feature commits from `main` (released in v2.1.0-rc) to `release/2.0` via cherry-pick. ## Commits ported (chronological) | PR | Title | |----|-------| | #3450 | Fix GraphQL aggregation features disabled when runtime.graphql config section is absent | | #3694 | Database policy support for PUT/PATCH operations - PostgreSQL | | #3728 | Add support for DateTime filters in PostgreSQL | | #3750 | Fix column mapping in GroupBy and aggregation queries | | #3741 | Add groupby/aggregation support for PostgreSQL in GraphQL | | #3753 | Enhance test coverage for GraphQL queries by adding orderBy clause | ## Notes - All six cherry-picks applied cleanly. - One manual adjustment in `SqlMutationEngine.cs` (part of #3694 port): the original referenced `effectiveOperationType` (a local introduced by the unrelated refactor #3287, which is not in `release/2.0`). Substituted `context.OperationType`, which is functionally equivalent in that non-upsert branch and matches the `release/2.0` convention. Folded into the #3694 commit. - Solution builds clean (0 warnings, 0 errors). - Integration tests (PostgreSql/MsSql) require live databases and were not run locally. --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com> Co-authored-by: Aniruddh Munde <anmunde@microsoft.com> Co-authored-by: Souvik Ghosh <souvikofficial04@gmail.com> Co-authored-by: Arjun Narendra <arjunnarendra1@gmail.com> Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com> Co-authored-by: Arpit Gupta <106474712+ar-guptaar@users.noreply.github.com> Co-authored-by: ARPIT GUPTA <guptaar@microsoft.com> Co-authored-by: Anusha Kolan <anushakolan10@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
GraphQL aggregation features (
groupBy,sum,avg,min,max,count) were silently disabled for users whose config lacked an explicitruntime.graphqlsection, even thoughEnableAggregationdefaults totrue.What is this change?
Bug fix:
RuntimeConfig.EnableAggregationlogic inversionThe property used
&&logic, returningfalsewhenRuntimeorRuntime.GraphQLwasnull. This is inconsistent with every analogous property (e.g.IsGraphQLEnabled) which use||logic to treat absence as "use default (enabled)":Additional fixes:
GraphQLSchemaCreator.OnConfigChangednow updates_isAggregationEnabledon hot-reload (was omitted, causing stale state)schemas/dab.draft.schema.json: addedenable-aggregationtoruntime.graphqlproperties — it was missing despiteadditionalProperties: false, meaning any config explicitly setting the flag would fail schema validationTest refactoring (per code review feedback):
LoadConfigprivate helper inRuntimeConfigLoaderTeststo eliminate repeated mock-filesystem setup across allEnableAggregationtestsEnableAggregation_WhenExplicitlyDisabled_ReturnsFalseandEnableAggregation_WhenExplicitlyEnabled_ReturnsTrueinto a single parameterized[DataTestMethod](EnableAggregation_WhenExplicitlySet_ReturnsConfiguredValue) using[DataRow(true)]and[DataRow(false)]Build_WithMssqlAndAggregationEnabled_AddsGroupByToConnectionTypeandBuild_WithPostgreSqlAndAggregationEnabled_DoesNotAddGroupByToConnectionTypeinto a single parameterized[DataTestMethod](Build_WithAggregationEnabled_GroupByPresenceMatchesDatabaseSupport) covering MSSQL, DWSQL (groupBy present), PostgreSQL, and MySQL (groupBy absent)How was this tested?
RuntimeConfigLoaderTests:EnableAggregationdefaults totruewhenruntimeorruntime.graphqlsections are absent; a single parameterized test (EnableAggregation_WhenExplicitlySet_ReturnsConfiguredValue) covers bothtrueandfalseexplicit values using[DataRow]. A sharedLoadConfighelper eliminates repeated mock-filesystem setup.QueryBuilderTests: a single parameterized test (Build_WithAggregationEnabled_GroupByPresenceMatchesDatabaseSupport) covers MSSQL and DWSQL (groupBy present) and PostgreSQL and MySQL (groupBy absent), plus a test confirming groupBy is omitted when aggregation is disabled.Sample Request(s)
With a config that has no explicit
runtime.graphqlsection, the following now works as expected for MSSQL/DWSQL entities:{ books { groupBy(fields: [price]) { fields { price } aggregations { count sum(field: price) avg(field: price) max(field: price) min(field: price) } } } }