Skip to content

Commit 1d1e812

Browse files
seantleonardseverussundarAniruddh25
authored
Stored Procedure support for new Execute operation - REST and GraphQL (#1107)
* prelim changes. * Updating operation/action handling in validation and ensuring SP's are only allowed to define execute. Also, GraphQL field generation properly prefixes execute * Proper operation resolution and execute field naming for SP's * Updates for adding Operation configuraiton for StoredProcedure GraphQL entity settings. * updated processing. * Updated Authorization and REST processing of EXECUTE for SPs. * Revisions and helper methods, and method comments added. * Add tests. * Added more comments. * Added more GraphQL tests and added more comments referencing GraphQL specification to note different behavior between QueryBuilder and MutationBuilder * Fixed spacing and usings. * update reference configuration for stored procedures. * remove whitespace. and fix broken query generation logic. * updated tests. * Fix permissions operations to be execute for stored procedure entities created via CLI * Updated CLI handling of execute operation. * Fix CLI tests to be compatible with Execute operation for stored procedures. * fix permissions on mssqlcommands script. * Updated tests and Configuration handling. * Addressing PR feedback. * fix formatting * fixed test. * CLI - Execute action for stored procedures (#1129) * adds CLI options --rest.methods, --graph.operations * Adds options --rest.methods, --graphql.operation * adds execute as a valid operation * changes required in add command * changes for add command * skipping update command test * adding unit tests for add command * adding tests, schema changes * few modifications, more tests * adds method summary * changes to method summary * improves helptext for both the options * Apply suggestions from code review applied from Ani's suggestions. Co-authored-by: Aniruddh Munde <[email protected]> * Addressed PR feedback. * Removing instances where "operation" appeared in non-stored procedure entity configuration JSON as null. * Add verbose config settings for GraphQL in order to not have operation in non-sp entity types. --------- Co-authored-by: Sean Leonard <[email protected]> Co-authored-by: Aniruddh Munde <[email protected]> * updates for compatibility * Addressing PR feedback. * refining logic. * added code comments. * Updated spacing. * Execute Action - Update Command (#1139) * changes to creation of rest and graphql objects in CLI * adds rest.methods and graphql.operation options to update command * adds de-serialization to more places * fix formatting * using singular,plural names from config * chaning graphql operation of GetBooks to query * adding rest method to rest api test helper functions * Adding summary for methods * adding more tests for sp rest, graphql options * adding more tests * fix formatting * fix formatting * fixing typo * renaming variables * adding tests for update command * updating tests, removing debug print statements * fix formatting * adding dab commands needed for tests * Ignoring breaking tests * updating dab command * updated from Feedback * Remove stored procedure entities from sql reference json schema since not all SQL databases are supported for those entities. Added to MSSQL json schema reference. * REST json key `method` to `methods` * Clean up nits and add comments to methods without descriptions. * added comments * added Sales table back to reference. * remove changed file. * more concise switch + code comments. * more code comments, renames for clarification and removal of empty lines. * remove using. * addressing nits * fixing deserialization of graphql operation, removing ignore in querybuilder mutationbuilder tests * fixing deserialization test * fix formatting * updating rest methods for GetBook, GetBooks * Including REST find tests for SPs * adding rest methods to find api tests * enabling source type conversion * fixing formatting * updating logic for update rest,grapql options * remove rest command from cosmos db commands * fix return type from 403 to 405 to match HTTP spec and fix type casting. * resolve nits in PR feedback. * Address feedback from PR * address feedback for renaming GetGraphQLType() to GetGraphQLEnabledOrPath() * CLI resolve operations for permission based on SourceType, special handling for StoredProcedure * fix empty code * additional check for stored proc * Fix flip flopped valid ops * Update return types and remove unnecessary method. * update valid RestMethod calculation. * Additional Stored Procedure Check. * Remove dupe code and address feedback. removed unneeded logging. * nit: remove ending tabs from line 243:249 * Extra line * update check. * address comment. * adding method summary, modifying a check --------- Co-authored-by: Shyam Sundar J <[email protected]> Co-authored-by: Aniruddh Munde <[email protected]>
1 parent ed8a86c commit 1d1e812

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2190
-674
lines changed

ConfigGenerators/CosmosCommands.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
init --config "dab-config.CosmosDb_NoSql.json" --database-type "cosmosdb_nosql" --connection-string "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" --cosmosdb_nosql-database "graphqldb" --cosmosdb_nosql-container "planet" --graphql-schema "schema.gql" --host-mode Development --cors-origin "http://localhost:5000"
2-
add Planet --config "dab-config.CosmosDb_NoSql.json" --source "graphqldb.planet" --permissions "anonymous:create,read,update,delete" --rest false --graphql "Planet:Planets"
2+
add Planet --config "dab-config.CosmosDb_NoSql.json" --source "graphqldb.planet" --permissions "anonymous:create,read,update,delete" --graphql "Planet:Planets"
33
update Planet --config "dab-config.CosmosDb_NoSql.json" --permissions "authenticated:create,read,update,delete"
4-
add Character --config "dab-config.CosmosDb_NoSql.json" --source "graphqldb.character" --permissions "authenticated:create,read,update,delete" --rest false --graphql "Character:Characters"
5-
add StarAlias --config "dab-config.CosmosDb_NoSql.json" --source "graphqldb.star" --permissions "anonymous:create,read,update,delete" --rest false --graphql "Star:Stars"
4+
add Character --config "dab-config.CosmosDb_NoSql.json" --source "graphqldb.character" --permissions "authenticated:create,read,update,delete" --graphql "Character:Characters"
5+
add StarAlias --config "dab-config.CosmosDb_NoSql.json" --source "graphqldb.star" --permissions "anonymous:create,read,update,delete" --graphql "Star:Stars"
66
update StarAlias --config "dab-config.CosmosDb_NoSql.json" --source "graphqldb.star" --permissions "authenticated:create,read,update,delete"

ConfigGenerators/MsSqlCommands.txt

+18-18
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ add Journal --config "dab-config.MsSql.json" --source "journals" --rest true --g
2525
add ArtOfWar --config "dab-config.MsSql.json" --source "aow" --rest true --graphql false --permissions "anonymous:*"
2626
add series --config "dab-config.MsSql.json" --source "series" --permissions "anonymous:*"
2727
add Sales --config "dab-config.MsSql.json" --source "sales" --permissions "anonymous:*" --rest true --graphql true
28-
add GetBooks --config "dab-config.MsSql.json" --source "get_books" --source.type "stored-procedure" --permissions "anonymous:read" --rest true --graphql true
29-
add GetBook --config "dab-config.MsSql.json" --source "get_book_by_id" --source.type "stored-procedure" --permissions "anonymous:read" --rest true --graphql false
30-
add GetPublisher --config "dab-config.MsSql.json" --source "get_publisher_by_id" --source.type "stored-procedure" --source.params "id:1" --permissions "anonymous:read" --rest true --graphql true
31-
add InsertBook --config "dab-config.MsSql.json" --source "insert_book" --source.type "stored-procedure" --source.params "title:randomX,publisher_id:1234" --permissions "anonymous:create" --rest true --graphql true
32-
add CountBooks --config "dab-config.MsSql.json" --source "count_books" --source.type "stored-procedure" --permissions "anonymous:read" --rest true --graphql true
33-
add DeleteLastInsertedBook --config "dab-config.MsSql.json" --source "delete_last_inserted_book" --source.type "stored-procedure" --permissions "anonymous:delete" --rest true --graphql true
34-
add UpdateBookTitle --config "dab-config.MsSql.json" --source "update_book_title" --source.type "stored-procedure" --source.params "id:1,title:Testing Tonight" --permissions "anonymous:update" --rest true --graphql true
35-
add GetAuthorsHistoryByFirstName --config "dab-config.MsSql.json" --source "get_authors_history_by_first_name" --source.type "stored-procedure" --source.params "firstName:Aaron" --permissions "anonymous:read" --rest true --graphql SearchAuthorByFirstName
36-
add InsertAndDisplayAllBooksUnderGivenPublisher --config "dab-config.MsSql.json" --source "insert_and_display_all_books_for_given_publisher" --source.type "stored-procedure" --source.params "title:MyTitle,publisher_name:MyPublisher" --permissions "anonymous:create" --rest true --graphql true
28+
add GetBooks --config "dab-config.MsSql.json" --source "get_books" --source.type "stored-procedure" --permissions "anonymous:execute" --rest true --graphql true
29+
add GetBook --config "dab-config.MsSql.json" --source "get_book_by_id" --source.type "stored-procedure" --permissions "anonymous:execute" --rest true --graphql false
30+
add GetPublisher --config "dab-config.MsSql.json" --source "get_publisher_by_id" --source.type "stored-procedure" --source.params "id:1" --permissions "anonymous:execute" --rest true --graphql true
31+
add InsertBook --config "dab-config.MsSql.json" --source "insert_book" --source.type "stored-procedure" --source.params "title:randomX,publisher_id:1234" --permissions "anonymous:execute" --rest true --graphql true
32+
add CountBooks --config "dab-config.MsSql.json" --source "count_books" --source.type "stored-procedure" --permissions "anonymous:execute" --rest true --graphql true
33+
add DeleteLastInsertedBook --config "dab-config.MsSql.json" --source "delete_last_inserted_book" --source.type "stored-procedure" --permissions "anonymous:execute" --rest true --graphql true
34+
add UpdateBookTitle --config "dab-config.MsSql.json" --source "update_book_title" --source.type "stored-procedure" --source.params "id:1,title:Testing Tonight" --permissions "anonymous:execute" --rest true --graphql true
35+
add GetAuthorsHistoryByFirstName --config "dab-config.MsSql.json" --source "get_authors_history_by_first_name" --source.type "stored-procedure" --source.params "firstName:Aaron" --permissions "anonymous:execute" --rest true --graphql SearchAuthorByFirstName
36+
add InsertAndDisplayAllBooksUnderGivenPublisher --config "dab-config.MsSql.json" --source "insert_and_display_all_books_for_given_publisher" --source.type "stored-procedure" --source.params "title:MyTitle,publisher_name:MyPublisher" --permissions "anonymous:execute" --rest true --graphql true
3737
add GQLmappings --config "dab-config.MsSql.json" --source "GQLmappings" --permissions "anonymous:*" --rest true --graphql true
3838
update GQLmappings --config "dab-config.MsSql.json" --map "__column1:column1,__column2:column2" --permissions "authenticated:*"
3939
update Publisher --config "dab-config.MsSql.json" --permissions "authenticated:create,read,update,delete" --rest true --graphql true --relationship books --target.entity Book --cardinality many
@@ -116,13 +116,13 @@ update Journal --config "dab-config.MsSql.json" --permissions "policy_tester_upd
116116
update Journal --config "dab-config.MsSql.json" --permissions "policy_tester_update_noread:delete" --fields.include "*" --policy-database "@item.id eq 1"
117117
update Journal --config "dab-config.MsSql.json" --permissions "authorizationHandlerTester:read"
118118
update ArtOfWar --config "dab-config.MsSql.json" --permissions "authenticated:*" --map "DetailAssessmentAndPlanning:始計,WagingWar:作戰,StrategicAttack:謀攻,NoteNum:┬─┬ノ( º _ ºノ)"
119-
update GetBook --config "dab-config.MsSql.json" --permissions "authenticated:read"
120-
update GetPublisher --config "dab-config.MsSql.json" --permissions "authenticated:read"
121-
update GetBooks --config "dab-config.MsSql.json" --permissions "authenticated:read"
122-
update InsertBook --config "dab-config.MsSql.json" --permissions "authenticated:create"
123-
update CountBooks --config "dab-config.MsSql.json" --permissions "authenticated:read"
124-
update DeleteLastInsertedBook --config "dab-config.MsSql.json" --permissions "authenticated:delete"
125-
update UpdateBookTitle --config "dab-config.MsSql.json" --permissions "authenticated:update"
119+
update GetBook --config "dab-config.MsSql.json" --permissions "authenticated:execute" --rest.methods "Get"
120+
update GetPublisher --config "dab-config.MsSql.json" --permissions "authenticated:execute"
121+
update GetBooks --config "dab-config.MsSql.json" --permissions "authenticated:execute" --graphql.operation "Query" --rest.methods "Get"
122+
update InsertBook --config "dab-config.MsSql.json" --permissions "authenticated:execute"
123+
update CountBooks --config "dab-config.MsSql.json" --permissions "authenticated:execute"
124+
update DeleteLastInsertedBook --config "dab-config.MsSql.json" --permissions "authenticated:execute"
125+
update UpdateBookTitle --config "dab-config.MsSql.json" --permissions "authenticated:execute"
126126
update Sales --config "dab-config.MsSql.json" --permissions "authenticated:*"
127-
update GetAuthorsHistoryByFirstName --config "dab-config.MsSql.json" --permissions "authenticated:read"
128-
update InsertAndDisplayAllBooksUnderGivenPublisher --config "dab-config.MsSql.json" --permissions "authenticated:create"
127+
update GetAuthorsHistoryByFirstName --config "dab-config.MsSql.json" --permissions "authenticated:execute"
128+
update InsertAndDisplayAllBooksUnderGivenPublisher --config "dab-config.MsSql.json" --permissions "authenticated:execute"

ConfigGenerators/dab-config.mssql.reference.json

+58-22
Original file line numberDiff line numberDiff line change
@@ -915,15 +915,18 @@
915915
"object": "get_books"
916916
},
917917
"rest": true,
918-
"graphql": true,
918+
"graphql": {
919+
"type": "GetBooks",
920+
"operation": "query"
921+
},
919922
"permissions": [
920923
{
921924
"role": "anonymous",
922-
"actions": [ "read" ]
925+
"actions": [ "execute" ]
923926
},
924927
{
925928
"role": "authenticated",
926-
"actions": [ "read" ]
929+
"actions": [ "execute" ]
927930
}
928931
]
929932
},
@@ -932,16 +935,19 @@
932935
"type": "stored-procedure",
933936
"object": "get_book_by_id"
934937
},
935-
"rest": true,
938+
"rest": {
939+
"path": "GetBook",
940+
"methods": [ "GET" ]
941+
},
936942
"graphql": false,
937943
"permissions": [
938944
{
939945
"role": "anonymous",
940-
"actions": [ "read" ]
946+
"actions": [ "execute" ]
941947
},
942948
{
943949
"role": "authenticated",
944-
"actions": [ "read" ]
950+
"actions": [ "execute" ]
945951
}
946952
]
947953
},
@@ -978,53 +984,68 @@
978984
},
979985
"key-fields": []
980986
},
981-
"rest": true,
987+
"rest": {
988+
"path": "InsertBook",
989+
"methods": [ "POST" ]
990+
},
982991
"permissions": [
983992
{
984993
"role": "anonymous",
985994
"actions": [
986-
"create"
995+
"execute"
987996
]
988997
},
989998
{
990999
"role": "authenticated",
9911000
"actions": [
992-
"create"
1001+
"execute"
9931002
]
9941003
}
9951004
],
996-
"graphql": true
1005+
"graphql": {
1006+
"type": "InsertBook",
1007+
"operation": "mutation"
1008+
}
9971009
},
9981010
"CountBooks": {
9991011
"source": {
10001012
"type": "stored-procedure",
10011013
"object": "count_books",
10021014
"key-fields": []
10031015
},
1004-
"rest": true,
1016+
"rest": {
1017+
"path": "CountBooks",
1018+
"methods": [ "GET" ]
1019+
},
10051020
"permissions": [
10061021
{
10071022
"role": "anonymous",
10081023
"actions": [
1009-
"read"
1024+
"execute"
10101025
]
10111026
},
10121027
{
10131028
"role": "authenticated",
10141029
"actions": [
1015-
"read"
1030+
"execute"
10161031
]
10171032
}
10181033
],
1019-
"graphql": true
1034+
"graphql": {
1035+
"type": "CountBooks",
1036+
"operation": "query"
1037+
}
10201038
},
10211039
"DeleteLastInsertedBook": {
10221040
"source": {
10231041
"type": "stored-procedure",
10241042
"object": "delete_last_inserted_book",
10251043
"key-fields": []
10261044
},
1027-
"rest": true,
1045+
"rest": {
1046+
"path": "DeleteLastInsertedBook",
1047+
"methods": [ "DELETE" ]
1048+
},
10281049
"permissions": [
10291050
{
10301051
"role": "anonymous",
@@ -1039,7 +1060,10 @@
10391060
]
10401061
}
10411062
],
1042-
"graphql": true
1063+
"graphql": {
1064+
"type": "DeleteLastInsertedBook",
1065+
"operation": "mutation"
1066+
}
10431067
},
10441068
"UpdateBookTitle": {
10451069
"source": {
@@ -1051,22 +1075,28 @@
10511075
},
10521076
"key-fields": []
10531077
},
1054-
"rest": true,
1078+
"rest": {
1079+
"path": "UpdateBookTitle",
1080+
"methods": [ "PUT", "PATCH" ]
1081+
},
10551082
"permissions": [
10561083
{
10571084
"role": "anonymous",
10581085
"actions": [
1059-
"update"
1086+
"execute"
10601087
]
10611088
},
10621089
{
10631090
"role": "authenticated",
10641091
"actions": [
1065-
"update"
1092+
"execute"
10661093
]
10671094
}
10681095
],
1069-
"graphql": true
1096+
"graphql": {
1097+
"type": "UpdateBookTitle",
1098+
"operation": "mutation"
1099+
}
10701100
},
10711101
"GetPublisher": {
10721102
"source": {
@@ -1076,7 +1106,10 @@
10761106
"id": 1
10771107
}
10781108
},
1079-
"rest": true,
1109+
"rest": {
1110+
"path": "GetPublisher",
1111+
"methods": [ "GET" ]
1112+
},
10801113
"permissions": [
10811114
{
10821115
"role": "anonymous",
@@ -1091,7 +1124,10 @@
10911124
]
10921125
}
10931126
],
1094-
"graphql": true
1127+
"graphql": {
1128+
"type": "GetPublisher",
1129+
"operation": "query"
1130+
}
10951131
},
10961132
"GQLmappings": {
10971133
"source": {

0 commit comments

Comments
 (0)