-
Notifications
You must be signed in to change notification settings - Fork 357
Use config parameter descriptions in GraphQL stored procedure args #3733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Anusha Kolan (anushakolan)
merged 12 commits into
main
from
dev/anushakolan/issue-3500-param-descriptions
Aug 6, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
558c2ed
Use config parameter descriptions in GraphQL stored procedure args
anushakolan cc39f40
Added additional tests
anushakolan 4d1d10b
Merge branch 'main' into dev/anushakolan/issue-3500-param-descriptions
anushakolan 94c159a
Merge branch 'main' into dev/anushakolan/issue-3500-param-descriptions
anushakolan c1f21b6
Merge branch 'main' into dev/anushakolan/issue-3500-param-descriptions
anushakolan b5be078
Merge branch 'main' into dev/anushakolan/issue-3500-param-descriptions
anushakolan dbfd82e
Merge remote-tracking branch 'origin/main' into dev/anushakolan/issue…
anushakolan 9c77906
fix(graphql): surface SP param descriptions in GraphQL schema; add du…
anushakolan 3506322
fix: remove unused usings in StoredProcedureBuilderTests
anushakolan 683b8a3
Merge branch 'main' into dev/anushakolan/issue-3500-param-descriptions
anushakolan a900b19
fix: address PR review comments - Ordinal comparer, restore provider …
anushakolan 19c07ad
fix: move duplicate SP param check to run in both dev and production …
anushakolan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163 changes: 163 additions & 0 deletions
163
...ervice.Tests/GraphQLBuilder/Sql/StoredProcedureBuilderDescriptionMsSqlIntegrationTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Azure.DataApiBuilder.Config.DatabasePrimitives; | ||
| using Azure.DataApiBuilder.Config.ObjectModel; | ||
| using Azure.DataApiBuilder.Core.Configurations; | ||
| using Azure.DataApiBuilder.Service.GraphQLBuilder; | ||
| using Azure.DataApiBuilder.Service.Tests.SqlTests; | ||
| using HotChocolate.Language; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace Azure.DataApiBuilder.Service.Tests.GraphQLBuilder.Sql | ||
| { | ||
| /// <summary> | ||
| /// Integration tests that verify stored-procedure parameter descriptions flow | ||
| /// end-to-end through the full production pipeline: | ||
| /// config parameters.description | ||
| /// → SqlMetadataProvider.FillSchemaForStoredProcedureAsync (merges onto ParameterDefinition) | ||
| /// → GraphQLStoredProcedureBuilder.GenerateStoredProcedureSchema (reads description) | ||
| /// → GraphQL argument description | ||
| /// </summary> | ||
| [TestClass, TestCategory(TestCategory.MSSQL)] | ||
| public class StoredProcedureBuilderDescriptionMsSqlIntegrationTests : SqlTestBase | ||
| { | ||
| private static RuntimeConfig _baseConfig; | ||
|
|
||
| [ClassInitialize] | ||
| public static async Task SetupAsync(TestContext context) | ||
| { | ||
| DatabaseEngine = TestCategory.MSSQL; | ||
| await InitializeTestFixture(); | ||
| _baseConfig = SqlTestHelper.SetupRuntimeConfig(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies that a description configured on a stored-procedure parameter in the | ||
| /// runtime config is propagated through the SQL metadata provider and reflected in | ||
| /// the generated GraphQL argument description. | ||
| /// | ||
| /// Uses the existing <c>get_book_by_id</c> stored procedure (defined in the MsSql | ||
| /// test schema) with a config-side description override on its <c>id</c> parameter. | ||
| /// </summary> | ||
| [TestMethod] | ||
| public async Task StoredProcedure_GraphQLArgDescription_UsesConfigDescriptionAfterMetadataInit() | ||
| { | ||
|
anushakolan marked this conversation as resolved.
|
||
| const string entityName = "GetBookWithParamDesc"; | ||
| const string configDescription = "The unique identifier for the book (from config)"; | ||
|
|
||
| Entity tamperedEntity = new( | ||
| Source: new( | ||
| "get_book_by_id", | ||
| EntitySourceType.StoredProcedure, | ||
| Parameters: new List<ParameterMetadata> | ||
| { | ||
| new() { Name = "id", Description = configDescription } | ||
| }, | ||
| KeyFields: null), | ||
| GraphQL: new(entityName, entityName, Enabled: true, Operation: GraphQLOperation.Query), | ||
| Rest: new(Enabled: false), | ||
| Fields: null, | ||
| Permissions: new[] | ||
| { | ||
| new EntityPermission( | ||
| Role: "anonymous", | ||
| Actions: new[] | ||
| { | ||
| new EntityAction(Action: EntityActionOperation.Execute, Fields: null, Policy: null) | ||
| }) | ||
| }, | ||
| Relationships: null, | ||
| Mappings: null, | ||
| Mcp: null); | ||
|
|
||
| Dictionary<string, Entity> entityMap = new() { [entityName] = tamperedEntity }; | ||
| RuntimeConfig tamperedConfig = _baseConfig with { Entities = new(entityMap) }; | ||
| RuntimeConfigProvider tamperedProvider = TestHelper.GenerateInMemoryRuntimeConfigProvider(tamperedConfig); | ||
| try | ||
| { | ||
| SetUpSQLMetadataProvider(tamperedProvider); | ||
| await _sqlMetadataProvider.InitializeAsync(); | ||
|
|
||
| DatabaseObject dbObject = _sqlMetadataProvider.EntityToDatabaseObject[entityName]; | ||
| FieldDefinitionNode field = GraphQLStoredProcedureBuilder.GenerateStoredProcedureSchema( | ||
| name: new NameNode(entityName), | ||
| entity: tamperedEntity, | ||
| dbObject: dbObject); | ||
|
|
||
| InputValueDefinitionNode idArg = field.Arguments.First(a => a.Name.Value == "id"); | ||
| Assert.IsNotNull(idArg.Description); | ||
| Assert.AreEqual(expected: configDescription, actual: idArg.Description!.Value); | ||
| } | ||
| finally | ||
| { | ||
| RuntimeConfigProvider sharedProvider = TestHelper.GenerateInMemoryRuntimeConfigProvider(_baseConfig); | ||
| SetUpSQLMetadataProvider(sharedProvider); | ||
| await _sqlMetadataProvider.InitializeAsync(); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Verifies that when no description is set on a stored-procedure parameter in the | ||
| /// runtime config the generated GraphQL argument falls back to the default | ||
| /// description text. Exercises the same full pipeline as the positive-case test. | ||
| /// </summary> | ||
| [TestMethod] | ||
| public async Task StoredProcedure_GraphQLArgDescription_FallsBackToDefaultTextWhenNoConfigDescription() | ||
| { | ||
| const string entityName = "GetBookNoDesc"; | ||
|
|
||
| Entity tamperedEntity = new( | ||
| Source: new( | ||
| "get_book_by_id", | ||
| EntitySourceType.StoredProcedure, | ||
| Parameters: new List<ParameterMetadata> { new() { Name = "id" } }, | ||
| KeyFields: null), | ||
| GraphQL: new(entityName, entityName, Enabled: true, Operation: GraphQLOperation.Query), | ||
| Rest: new(Enabled: false), | ||
| Fields: null, | ||
| Permissions: new[] | ||
| { | ||
| new EntityPermission( | ||
| Role: "anonymous", | ||
| Actions: new[] | ||
| { | ||
| new EntityAction(Action: EntityActionOperation.Execute, Fields: null, Policy: null) | ||
| }) | ||
| }, | ||
| Relationships: null, | ||
| Mappings: null, | ||
| Mcp: null); | ||
|
|
||
| Dictionary<string, Entity> entityMap = new() { [entityName] = tamperedEntity }; | ||
| RuntimeConfig tamperedConfig = _baseConfig with { Entities = new(entityMap) }; | ||
| RuntimeConfigProvider tamperedProvider = TestHelper.GenerateInMemoryRuntimeConfigProvider(tamperedConfig); | ||
| try | ||
| { | ||
| SetUpSQLMetadataProvider(tamperedProvider); | ||
| await _sqlMetadataProvider.InitializeAsync(); | ||
|
|
||
| DatabaseObject dbObject = _sqlMetadataProvider.EntityToDatabaseObject[entityName]; | ||
| FieldDefinitionNode field = GraphQLStoredProcedureBuilder.GenerateStoredProcedureSchema( | ||
| name: new NameNode(entityName), | ||
| entity: tamperedEntity, | ||
| dbObject: dbObject); | ||
|
|
||
| InputValueDefinitionNode idArg = field.Arguments.First(a => a.Name.Value == "id"); | ||
| Assert.IsNotNull(idArg.Description); | ||
| Assert.AreEqual( | ||
| expected: $"parameters for {entityName} stored-procedure", | ||
| actual: idArg.Description!.Value); | ||
| } | ||
| finally | ||
| { | ||
| RuntimeConfigProvider sharedProvider = TestHelper.GenerateInMemoryRuntimeConfigProvider(_baseConfig); | ||
| SetUpSQLMetadataProvider(sharedProvider); | ||
| await _sqlMetadataProvider.InitializeAsync(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.