Skip to content

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

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-graphql-aggregation-features
Draft

Fix GraphQL aggregation features disabled when runtime.graphql config section is absent#3450
Copilot wants to merge 4 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
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]: GraphQL Aggregation features do not exist in DAB 2.0.0-rc schema

2 participants