Skip to content

Commit b928be7

Browse files
committed
Fix stored procedure operation types with length-limited regex
- Add length limiters ({1,500} and {1,200}) to regex patterns in config-generator.ps1 - Prevents over-matching that was incorrectly changing InsertBook from mutation to query - Fixes GetBooks, GetPublisher, and GetAuthorsHistoryByFirstName to be queries (read operations) - Preserves InsertBook, CountBooks, DeleteLastInsertedBook, UpdateBookTitle as mutations (write operations) - Regenerated both MsSql and DwSql configs with refined patterns
1 parent 666d97b commit b928be7

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

config-generators/config-generator.ps1

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,18 @@ foreach($databaseType in $databaseTypes){
7373

7474
# Post-process MsSql and DwSql configs to fix stored procedure GraphQL operations
7575
# The CLI currently ignores --graphql.operation parameter for stored procedures,
76-
# defaulting them to 'mutation'. We manually fix specific procedures that should be 'query'.
76+
# defaulting them to 'mutation'. We manually fix ONLY read operations that should be 'query'.
77+
# DO NOT fix write operations (Insert*, Update*, Delete*, Count*) - those should stay as 'mutation'.
7778
# Using text-based replacement to preserve original JSON formatting.
7879
if($databaseType -eq "mssql" -or $databaseType -eq "dwsql"){
7980
$configContent = Get-Content $configFile -Raw;
80-
# Fix GetBooks operation within its entity block
81-
$configContent = $configContent -replace '("GetBooks"[\s\S]*?"graphql"[\s\S]*?"operation":\s*)"mutation"', '$1"query"';
82-
# Fix GetPublisher operation within its entity block
83-
$configContent = $configContent -replace '("GetPublisher"[\s\S]*?"graphql"[\s\S]*?"operation":\s*)"mutation"', '$1"query"';
84-
# Fix GetAuthorsHistoryByFirstName operation within its entity block
85-
$configContent = $configContent -replace '("GetAuthorsHistoryByFirstName"[\s\S]*?"graphql"[\s\S]*?"operation":\s*)"mutation"', '$1"query"';
81+
# Fix GetBooks operation within its entity block (read operation)
82+
$configContent = $configContent -replace '("GetBooks"[\s\S]{1,500}?"graphql"[\s\S]{1,200}?"operation":\s*)"mutation"', '$1"query"';
83+
# Fix GetPublisher operation within its entity block (read operation)
84+
$configContent = $configContent -replace '("GetPublisher"[\s\S]{1,500}?"graphql"[\s\S]{1,200}?"operation":\s*)"mutation"', '$1"query"';
85+
# Fix GetAuthorsHistoryByFirstName operation within its entity block (read operation)
86+
$configContent = $configContent -replace '("GetAuthorsHistoryByFirstName"[\s\S]{1,500}?"graphql"[\s\S]{1,200}?"operation":\s*)"mutation"', '$1"query"';
87+
# Note: GetBook (singular) is already correctly set as query by the CLI
8688
Set-Content $configFile $configContent -Encoding UTF8 -NoNewline;
8789
}
8890
}

src/Service.Tests/dab-config.DwSql.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2449,7 +2449,7 @@
24492449
},
24502450
"graphql": {
24512451
"enabled": true,
2452-
"operation": "query",
2452+
"operation": "mutation",
24532453
"type": {
24542454
"singular": "CountBooks",
24552455
"plural": "CountBooks"

src/Service.Tests/dab-config.MsSql.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2897,7 +2897,7 @@
28972897
},
28982898
"graphql": {
28992899
"enabled": false,
2900-
"operation": "query",
2900+
"operation": "mutation",
29012901
"type": {
29022902
"singular": "GetBook",
29032903
"plural": "GetBooks"
@@ -2985,7 +2985,7 @@
29852985
},
29862986
"graphql": {
29872987
"enabled": true,
2988-
"operation": "query",
2988+
"operation": "mutation",
29892989
"type": {
29902990
"singular": "InsertBook",
29912991
"plural": "InsertBooks"
@@ -3156,7 +3156,7 @@
31563156
},
31573157
"graphql": {
31583158
"enabled": true,
3159-
"operation": "mutation",
3159+
"operation": "query",
31603160
"type": {
31613161
"singular": "SearchAuthorByFirstName",
31623162
"plural": "SearchAuthorByFirstNames"

0 commit comments

Comments
 (0)