Skip to content

server: apply source type name customization to aggregation predicate types (fix #10875) - #10890

Closed
russelgal wants to merge 1 commit into
hasura:masterfrom
russelgal:fix/aggregate-bool-exp-type-prefix
Closed

russelgal wants to merge 1 commit into
hasura:masterfrom
russelgal:fix/aggregate-bool-exp-type-prefix

Conversation

@russelgal

Copy link
Copy Markdown

Description

The input types of aggregation predicates — <table>_aggregate_bool_exp, <table>_aggregate_bool_exp_<function> and the arguments object types — are built without the source's type_names customization, while every type they reference is prefixed. Two sources with the same table name and distinct prefixes therefore clash on the bare type name as soon as both expose aggregation predicates for it, and the schema fails with Found conflicting definitions for GraphQL type.

With HASURA_FF_NAMING_CONVENTION_SEP_2023 enabled, these types now get the source's prefix and suffix like every other type of the source. Without the flag nothing changes.

Changelog

Component : server

Type: bugfix

Product: community-edition

Short Changelog

With HASURA_FF_NAMING_CONVENTION_SEP_2023 enabled, the source's type name prefix and suffix are applied to the input types of aggregation predicates, so sources with the same table name no longer clash on <table>_aggregate_bool_exp.

Long Changelog

Related Issues

#10875

Solution and Design

BoolExp.hs builds the table boolean expression type through the source customization (runMkTypename $ _rscTypeNames customization), whereas BoolExp/AggregationPredicates.hs passed the name straight to P.object, so MkTypename never ran there. The fix applies the same MkTypename to the three P.object names in that module.

Renaming existing types breaks clients that reference them by name (for example, in variable definitions), so following the discussion in #10875 the change sits behind the existing opt-in HASURA_FF_NAMING_CONVENTION_SEP_2023 flag, together with the other backward-incompatible naming fixes. The flag now affects hasura-default sources too, but only for this case and only when the source customizes type names; the docs of the flag are updated accordingly.

Steps to test and verify

Unit tests in Hasura.GraphQL.Schema.BoolExp.AggregationPredicatesSpec build the parser for a source with the pfx_ type prefix and check introspection:

  • with the flag: pfx_track_aggregate_bool_exp, pfx_track_aggregate_bool_exp_count (whose filter is pfx_track_bool_exp);
  • without the flag: the bare track_aggregate_bool_exp, as before.

cabal run graphql-engine:test:graphql-engine-tests passes: 1326 examples, 0 failures (CI run in the fork, GHC 9.14.1, -O0).

Limitations, known bugs & workarounds

  • Only the unit test suite was run; API tests (server/lib/api-tests) were not, and the two-source clash itself was not reproduced against a running server with this build.
  • Formatting was not checked with ormolu locally.
  • Without the flag the existing workarounds remain: HASURA_GRAPHQL_EXPERIMENTAL_FEATURES=hide_aggregation_predicates, or a custom_name on one of the tables.

Server checklist

Catalog upgrade

Does this PR change Hasura Catalog version?

  • No
  • Yes
    • Updated docs with SQL for downgrading the catalog

Metadata

Does this PR add a new Metadata feature?

  • No
  • Yes

GraphQL

  • No new GraphQL schema is generated
  • New GraphQL schema is being generated:
    • New types and typenames are correlated

Breaking changes

  • No Breaking changes

  • There are breaking changes:

    1. GraphQL API

      Schema Generation:

      • Change in any NamedType

Not breaking by default. With HASURA_FF_NAMING_CONVENTION_SEP_2023 enabled, the NamedTypes of aggregation predicate input types change for sources with type name customization.

🤖 Generated with Claude Code

… types

The input types of aggregation predicates (`<table>_aggregate_bool_exp`,
`<table>_aggregate_bool_exp_<function>` and the arguments object types) were
built without the source's `type_names` customization, while the types they
reference were prefixed. Two sources with the same table name and distinct
prefixes therefore clashed on the bare type name as soon as both exposed
aggregation predicates for it ("Found conflicting definitions for GraphQL
type").

Renaming existing types is a breaking change for clients that reference them
in variable definitions, so the customization is applied only with
HASURA_FF_NAMING_CONVENTION_SEP_2023 enabled, alongside the other opt-in naming
fixes.

Fixes hasura#10875

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@russelgal
russelgal requested review from a team as code owners October 22, 2026 08:23
hasura-bot added a commit that referenced this pull request Oct 22, 2026
… types (fix #10875)

GITHUB_PR_NUMBER: 10890
GITHUB_PR_URL: #10890

PR-URL: hasura/graphql-engine-mono#11815
GitOrigin-RevId: 8c91de0c9caaef059ec586cddcd9a468f1e34cd8
@hasura-bot hasura-bot closed this Oct 22, 2026
hasura-bot added a commit that referenced this pull request Oct 23, 2026
… types (fix #10875)

GITHUB_PR_NUMBER: 10890
GITHUB_PR_URL: #10890

PR-URL: hasura/graphql-engine-mono#11815
GitOrigin-RevId: 9301c1e3b15e50ebdd5de2320ca4630079c0eb94
hasura-bot added a commit that referenced this pull request Oct 23, 2026
… types (fix #10875)

GITHUB_PR_NUMBER: 10890
GITHUB_PR_URL: #10890

PR-URL: hasura/graphql-engine-mono#11815
GitOrigin-RevId: b27dc097941cf4bb3acbc30c43c4670a374e5c63
@hgiasac

hgiasac commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@russelgal thank you for contributing. The fix will be released soon in v2.51.2

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.

3 participants