Commit aa5c8a3
Fixing unintended update to GraphQL operation when updating REST methods (#1555)
## Why make this change?
- Closes #1554
1. Creating a stored procedure entity with graphql configured for Query
Command: `dab add getbooks --source "get_books" --source.type
"stored-procedure" --permissions "anonymous:execute" --graphql.operation
"query" `
Config Json (just the entities section):
```json
"entities": {
"getbooks": {
"source": {
"object": "get_books",
"type": "stored-procedure",
"parameters": null,
"key-fields": null
},
"graphql": {
"enabled": true,
"operation": "query",
"type": {
"singular": "getbooks",
"plural": "getbooks"
}
},
"rest": {
"enabled": true,
"path": null,
"methods": [
"post"
]
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "execute",
"fields": null,
"policy": {
"request": null,
"database": null
}
}
]
}
],
"mappings": null,
"relationships": null
}
}
```
2. Update the rest method to GET
Command: `dab update getbooks --rest.methods "GET"`
Config Json:
```json
"entities": {
"getbooks": {
"source": {
"object": "get_books",
"type": "stored-procedure",
"parameters": null,
"key-fields": null
},
"graphql": {
"enabled": true,
"operation": "mutation",
"type": {
"singular": "getbooks",
"plural": "getbooks"
}
},
"rest": {
"enabled": true,
"path": null,
"methods": [
"get"
]
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "execute",
"fields": null,
"policy": {
"request": null,
"database": null
}
}
]
}
],
"mappings": null,
"relationships": null
}
}
```
When updating the rest.methods, the graphql operation has lost its
original value of `query`. It now has the default value of `mutation`.
## What is this change?
- `ConfigGenerator.ConstructUpdatedGraphQLDetails()`: When GraphQL
operation is not updated, logic for preserving the existing configured
graphQL operation is added
- `EndToEndTests.TestUpdatingStoredProcedureWithRestMethods()`: Adds a
test case with the mentioned repro steps
## How was this tested?
- [x] Unit Tests
- [x] Manual Tests
## Sample Request(s)
- `dab add getbooks --source "getbooks" --source.type "stored-procedure"
--permissions "anonymous:execute" --graphql.operation "query"`
```json
"entities": {
"getbooks": {
"source": {
"object": "getbooks",
"type": "stored-procedure",
"parameters": null,
"key-fields": null
},
"graphql": {
"enabled": true,
"operation": "query",
"type": {
"singular": "getbooks",
"plural": "getbooks"
}
},
"rest": {
"enabled": true,
"path": null,
"methods": [
"post"
]
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "execute",
"fields": null,
"policy": {
"request": null,
"database": null
}
}
]
}
],
"mappings": null,
"relationships": null
}
}
```
- `dab update getbooks --rest.methods "get,patch"`
```json
"entities": {
"getbooks": {
"source": {
"object": "getbooks",
"type": "stored-procedure",
"parameters": null,
"key-fields": null
},
"graphql": {
"enabled": true,
"operation": "query",
"type": {
"singular": "getbooks",
"plural": "getbooks"
}
},
"rest": {
"enabled": true,
"path": null,
"methods": [
"get",
"patch"
]
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "execute",
"fields": null,
"policy": {
"request": null,
"database": null
}
}
]
}
],
"mappings": null,
"relationships": null
}
```
The `rest.methods` field is updated with the right values and the
existing value of `graphql.operation` is preserved
---------
Co-authored-by: Aaron Powell <[email protected]>
Co-authored-by: Sean Leonard <[email protected]>
Co-authored-by: Aniruddh Munde <[email protected]>
Co-authored-by: abhishekkumams <[email protected]>1 parent a52f103 commit aa5c8a3
File tree
3 files changed
+103
-1
lines changed- src
- Cli.Tests
- Snapshots
- Cli
3 files changed
+103
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
487 | 515 | | |
488 | 516 | | |
489 | 517 | | |
| |||
Lines changed: 68 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1094 | 1094 | | |
1095 | 1095 | | |
1096 | 1096 | | |
1097 | | - | |
| 1097 | + | |
1098 | 1098 | | |
1099 | 1099 | | |
1100 | 1100 | | |
| |||
1111 | 1111 | | |
1112 | 1112 | | |
1113 | 1113 | | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1114 | 1120 | | |
1115 | 1121 | | |
1116 | 1122 | | |
| |||
0 commit comments