Skip to content

Improve GraphQL naming conflict error to identify conflicting entities and operations - #3722

Open
RubenCerna2079 with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-duplicate-graphql-operations
Open

Improve GraphQL naming conflict error to identify conflicting entities and operations#3722
RubenCerna2079 with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-duplicate-graphql-operations

Conversation

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Why make this change?

When autoentities includes tables whose names differ only by singular/plural form (e.g. dbo.Category and dbo.Categories), DAB fails startup with a vague error that doesn't identify the other conflicting entity, the generated GraphQL names, or how to resolve the conflict.

What is this change?

  • RuntimeConfigValidator.ValidateEntitiesDoNotGenerateDuplicateQueriesOrMutation: Replaced HashSet<string> operation tracking with Dictionary<string, string> (operation → owning entity). Checks all operations (not short-circuit) to collect every conflicting name, then builds a structured error message including:
    • Both conflicting entity names
    • Singular/plural type names (for table/view entities)

Before:

Entity dbo_Category generates queries/mutation that already exist

After:

GraphQL naming conflict detected.

Entities:
  dbo_Categories
  dbo_Category

Both entities generate the following GraphQL names:
  Singular type: Category
  Plural type: Categories

Configure distinct GraphQL singular and plural names for one of the entities to resolve this conflict.

How was this tested?

  • Integration Tests
  • Unit Tests
    • Updated ValidateExceptionForDuplicateQueriesDueToEntityDefinitions helper to verify both conflicting entity names appear in the message
    • Updated all 6 existing duplicate-detection test call sites
    • Added ValidateAutoEntitiesWithSingularPluralNameCollisionGenerateDuplicateQueries covering the exact dbo.Category / dbo.Categories scenario

Sample Request(s)

N/A — error message improvement only; no API behavior changes.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI changed the title [WIP] Fix autoentities conflict with duplicate GraphQL operations Improve GraphQL naming conflict error to identify conflicting entities and operations Jul 14, 2026
Copilot AI requested a review from RubenCerna2079 July 14, 2026 21:25
@RubenCerna2079

Copy link
Copy Markdown
Contributor

@copilot Change the PR so that in the output message we don't include the operation names. Also, if possible we want to keep using the hashset we already used before. Try to change the logic as little as possible from what it was before the changes you made in this PR. The only change should be the error message.

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Change the PR so that in the output message we don't include the operation names. Also, if possible we want to keep using the hashset we already used before. Try to change the logic as little...

Done in 3a1f2d0. The changes are now minimal:

  • Reverted back to HashSet<string> with the original bool containsDuplicateOperationNames flag and || short-circuit chain
  • Added a parallel Dictionary<string, string> operationOwner (only used for error reporting) to identify which entity previously registered the conflicting operations
  • The error message now shows both conflicting entity names but no operation names

New message format:

GraphQL naming conflict detected.

Entities:
  dbo_Categories
  dbo_Category

Configure distinct GraphQL singular and plural names for one of the entities to resolve this conflict.

@RubenCerna2079
RubenCerna2079 marked this pull request as ready for review August 3, 2026 19:09
Copilot AI review requested due to automatic review settings August 3, 2026 19:09
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@RubenCerna2079

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).

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

Improves configuration-time GraphQL naming conflict diagnostics by augmenting RuntimeConfigValidator.ValidateEntitiesDoNotGenerateDuplicateQueriesOrMutation to track which entity “owns” each generated GraphQL operation name and by updating unit tests to validate the richer error output (including a new unit test for singular/plural auto-entity collisions).

Changes:

  • Enhanced duplicate GraphQL operation detection to retain the owning entity per operation and emit a more structured conflict message.
  • Updated existing unit tests to assert the new message shape (prefix + both entity names).
  • Added a unit test covering dbo.Category vs dbo.Categories (singular/plural collision) behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Core/Configurations/RuntimeConfigValidator.cs Tracks operation ownership and builds a more detailed GraphQL naming conflict exception message.
src/Service.Tests/UnitTests/ConfigValidationUnitTests.cs Updates duplicate-detection assertions and adds a new unit test for singular/plural auto-entity collisions.

Comment thread src/Core/Configurations/RuntimeConfigValidator.cs
Comment thread src/Core/Configurations/RuntimeConfigValidator.cs
@RubenCerna2079

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).

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

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[Known Issue]: Autoentities fail when table names generate duplicate GraphQL operations

5 participants