When autoentities includes objects such as dbo.Category and dbo.Categories, DAB automatically derives entity and GraphQL names from each database object.
During this process, DAB applies singularization and pluralization rules. Both object names can therefore resolve to the same GraphQL type and operation names:
Singular: Category
Plural: Categories
This causes the generated queries and mutations for one entity to conflict with those already generated for the other entity. DAB detects the duplicate names during runtime initialization and stops the application.
The current error states that the entity generates queries or mutations that already exist, but it does not identify:
- The other conflicting entity
- The generated GraphQL names
- The specific queries or mutations that conflict
- How the developer can resolve the conflict
Problem
DAB should return a clearer error that includes these details. For example:
GraphQL naming conflict detected.
Entities:
dbo.Category
dbo.Categories
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.
When
The following autoentities configuration includes two tables whose names differ only by singular and plural form:
"autoentities": {
"default": {
"patterns": {
"include": [
"dbo.Category",
"dbo.Categories"
]
}
}
}
And when
The database contains both tables:
Then
DAB fails during runtime initialization:
fail: Azure.DataApiBuilder.Service.Startup[0]
Unable to complete runtime initialization. Refer to exception for error details.
Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException: Entity dbo_Category generates queries/mutation that already exist
at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.HandleOrRecordException(Exception ex) in /_/src/Core/Configurations/RuntimeConfigValidator.cs:line 1675
at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.ValidateEntitiesDoNotGenerateDuplicateQueriesOrMutation(DatabaseType databaseType, RuntimeEntities entityCollection) in /_/src/Core/Configurations/RuntimeConfigValidator.cs:line 805
at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.ValidateEntityAndAutoentityConfigurations(RuntimeConfig runtimeConfig) in /_/src/Core/Configurations/RuntimeConfigValidator.cs:line 1769
at Azure.DataApiBuilder.Core.Services.SqlMetadataProvider`3.InitializeAsync() in /_/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs:line 346
at Azure.DataApiBuilder.Core.Services.MetadataProviders.MetadataProviderFactory.InitializeAsync() in /_/src/Core/Services/MetadataProviders/MetadataProviderFactory.cs:line 95
at Azure.DataApiBuilder.Service.Startup.PerformOnConfigChangeAsync(IApplicationBuilder app) in /_/src/Service/Startup.cs:line 1301
Expected behavior
DAB should continue to reject duplicate GraphQL names because allowing the conflict would create an ambiguous API schema.
However, the error should identify both entities and the generated names that conflict. It should also explain that the developer must assign distinct GraphQL singular and plural names.
Workaround
Exclude one or both conflicting tables from autoentities, then configure them explicitly under entities.
Explicit entity configuration allows the developer to assign GraphQL names that do not conflict with names generated for other entities.
For example, dbo.Category can retain the generated Category and Categories names while dbo.Categories uses CategoryCollection and CategoryCollections.
Entity example
"entities": {
"dbo_Categories": {
"source": {
"object": "dbo.Categories",
"type": "table"
},
"graphql": {
"type": {
"singular": "CategoryCollection",
"plural": "CategoryCollections"
}
},
"permissions": [
{
"role": "anonymous",
"actions": [
"*"
]
}
]
}
}
This produces distinct GraphQL names for the two entities and prevents the generated queries and mutations from colliding.
When
autoentitiesincludes objects such asdbo.Categoryanddbo.Categories, DAB automatically derives entity and GraphQL names from each database object.During this process, DAB applies singularization and pluralization rules. Both object names can therefore resolve to the same GraphQL type and operation names:
This causes the generated queries and mutations for one entity to conflict with those already generated for the other entity. DAB detects the duplicate names during runtime initialization and stops the application.
The current error states that the entity generates queries or mutations that already exist, but it does not identify:
Problem
DAB should return a clearer error that includes these details. For example:
When
The following
autoentitiesconfiguration includes two tables whose names differ only by singular and plural form:And when
The database contains both tables:
Then
DAB fails during runtime initialization:
Expected behavior
DAB should continue to reject duplicate GraphQL names because allowing the conflict would create an ambiguous API schema.
However, the error should identify both entities and the generated names that conflict. It should also explain that the developer must assign distinct GraphQL singular and plural names.
Workaround
Exclude one or both conflicting tables from
autoentities, then configure them explicitly underentities.Explicit entity configuration allows the developer to assign GraphQL names that do not conflict with names generated for other entities.
For example,
dbo.Categorycan retain the generatedCategoryandCategoriesnames whiledbo.CategoriesusesCategoryCollectionandCategoryCollections.Entity example
This produces distinct GraphQL names for the two entities and prevents the generated queries and mutations from colliding.