Skip to content

Fix GraphQL aggregation features disabled when runtime.graphql config section is absent#3450

Open
Copilot wants to merge 5 commits intomainfrom
copilot/fix-graphql-aggregation-features
Open

Fix GraphQL aggregation features disabled when runtime.graphql config section is absent#3450
Copilot wants to merge 5 commits intomainfrom
copilot/fix-graphql-aggregation-features

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

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)":

// 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

How was this tested?

  • Integration Tests
  • Unit Tests
    • 4 new RuntimeConfigLoaderTests: EnableAggregation defaults to true when runtime or runtime.graphql sections are absent; correctly honours explicit true/false
    • 3 new QueryBuilderTests: groupBy field added to connection type for MSSQL (supported), absent for PostgreSQL (not in AggregationEnabledDatabaseTypes), absent when disabled

Sample Request(s)

With a config that has no explicit runtime.graphql section, 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)
      }
    }
  }
}

Copilot AI and others added 2 commits April 15, 2026 22:16
…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>
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
Copilot AI requested a review from Aniruddh25 April 15, 2026 22:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.EnableAggregation defaulting behavior to treat missing runtime / runtime.graphql as “enabled”.
  • Updated GraphQLSchemaCreator hot-reload handling to refresh the aggregation-enabled flag.
  • Extended dab.draft.schema.json to allow runtime.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.

@Aniruddh25 Aniruddh25 added the 2.0 label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: GraphQL Aggregation features do not exist in DAB 2.0.0-rc schema

5 participants