You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Flag for Nested Mutations: CLI changes (#1983)
## Why make this change?
- Closes#1950
- Introduces a feature flag in the config for nested mutation
operations.
- Feature Flag format:
```json
"runtime":{
...
"graphql": {
...
"nested-mutations": {
"create": {
"enabled": true/false
}
}
}
}
```
- CLI Option: `--graphql.nested-create.enabled`. This option can be used
along with `init` command to enable/disable nested insert operation.
- By default, the nested mutation operations will be **disabled**.
- Nested Mutation operations are applicable only for MsSQL database
type. So, when the option `--graphql.nested-create.enabled` is used
along with other database types, it is not honored and nested mutation
operations will be disabled. Nested Mutation section will not be written
to the config file. In addition, a warning will be logged to let users
know that the option is inapplicable.
## What is this change?
- `dab.draft.schema.json` - The schema file is updated to contain
details about the new fields
- `InitOptions` - A new option `--graphql.nested-create.enabled` is
introduced for the `init` command.
- `NestedCreateOptionsConverter` - Custom converter to read & write the
options for nested insert operation from/to the config file
respectively.
- `NestedMutationOptionsConverter` - Custom converter to read & write
the options for nested mutation operations from/to the config file
respectively.
- `GraphQLRuntimeOptionsConverterFactory` - Updates the logic for
reading and writing the graphQL runtime section of the config file.
Incorporates logic for reading and writing the nested mutation operation
options.
- `dab-config.*.json`/`Multidab-config.*.json` - All the reference
config files are updated to include the new Nested Mutation options
## How was this tested?
- [x] Integration Tests
- [x] Unit Tests
- [x] Manual Tests
## Sample Commands
- **Nested Create Operations are enabled**:
`dab init --database-type mssql --connection-string connString
--graphql.nested-create.enabled true`

- **Nested Create Operations are disabled**:
`dab init --database-type mssql --connection-string connString
--graphql.nested-create.enabled false`

- **When --graphql.nested-create.graphql option is not used in the init
command**:
`dab init --database-type mssql --connection-string connString`

- **When --graphql.nested-create.graphql option is used with a database
type other than MsSQL**:

/// Test to validate the usage of --graphql.nested-create.enabled option of the init command for all database types.
136
+
///
137
+
/// 1. Behavior for database types other than MsSQL:
138
+
/// - Irrespective of whether the --graphql.nested-create.enabled option is used or not, fields related to nested-create will NOT be written to the config file.
139
+
/// - As a result, after deserialization of such a config file, the Runtime.GraphQL.NestedMutationOptions is expected to be null.
140
+
/// 2. Behavior for MsSQL database type:
141
+
///
142
+
/// a. When --graphql.nested-create.enabled option is used
143
+
/// - In this case, the fields related to nested mutation and nested create operations will be written to the config file.
144
+
/// "nested-mutations": {
145
+
/// "create": {
146
+
/// "enabled": true/false
147
+
/// }
148
+
/// }
149
+
/// After deserializing such a config file, the Runtime.GraphQL.NestedMutationOptions is expected to be non-null and the value of the "enabled" field is expected to be the same as the value passed in the init command.
150
+
///
151
+
/// b. When --graphql.nested-create.enabled option is not used
152
+
/// - In this case, fields related to nested mutation and nested create operations will NOT be written to the config file.
153
+
/// - As a result, after deserialization of such a config file, the Runtime.GraphQL.NestedMutationOptions is expected to be null.
154
+
///
155
+
/// </summary>
156
+
/// <param name="isNestedCreateEnabled">Value interpreted by the CLI for '--graphql.nested-create.enabled' option of the init command.
157
+
/// When not used, CLI interprets the value for the option as CliBool.None
158
+
/// When used with true/false, CLI interprets the value as CliBool.True/CliBool.False respectively.
159
+
/// </param>
160
+
/// <param name="expectedValueForNestedCreateEnabledFlag"> Expected value for the nested create enabled flag in the config file.</param>
161
+
[DataTestMethod]
162
+
[DataRow(CliBool.True,"mssql",DatabaseType.MSSQL,DisplayName="Init command with '--graphql.nested-create.enabled true' for MsSql database type")]
163
+
[DataRow(CliBool.False,"mssql",DatabaseType.MSSQL,DisplayName="Init command with '--graphql.nested-create.enabled false' for MsSql database type")]
164
+
[DataRow(CliBool.None,"mssql",DatabaseType.MSSQL,DisplayName="Init command without '--graphql.nested-create.enabled' option for MsSql database type")]
165
+
[DataRow(CliBool.True,"mysql",DatabaseType.MySQL,DisplayName="Init command with '--graphql.nested-create.enabled true' for MySql database type")]
166
+
[DataRow(CliBool.False,"mysql",DatabaseType.MySQL,DisplayName="Init command with '--graphql.nested-create.enabled false' for MySql database type")]
167
+
[DataRow(CliBool.None,"mysql",DatabaseType.MySQL,DisplayName="Init command without '--graphql.nested-create.enabled' option for MySql database type")]
168
+
[DataRow(CliBool.True,"postgresql",DatabaseType.PostgreSQL,DisplayName="Init command with '--graphql.nested-create.enabled true' for PostgreSql database type")]
169
+
[DataRow(CliBool.False,"postgresql",DatabaseType.PostgreSQL,DisplayName="Init command with '--graphql.nested-create.enabled false' for PostgreSql database type")]
170
+
[DataRow(CliBool.None,"postgresql",DatabaseType.PostgreSQL,DisplayName="Init command without '--graphql.nested-create.enabled' option for PostgreSql database type")]
171
+
[DataRow(CliBool.True,"dwsql",DatabaseType.DWSQL,DisplayName="Init command with '--graphql.nested-create.enabled true' for dwsql database type")]
172
+
[DataRow(CliBool.False,"dwsql",DatabaseType.DWSQL,DisplayName="Init command with '--graphql.nested-create.enabled false' for dwsql database type")]
173
+
[DataRow(CliBool.None,"dwsql",DatabaseType.DWSQL,DisplayName="Init command without '--graphql.nested-create.enabled' option for dwsql database type")]
174
+
[DataRow(CliBool.True,"cosmosdb_nosql",DatabaseType.CosmosDB_NoSQL,DisplayName="Init command with '--graphql.nested-create.enabled true' for cosmosdb_nosql database type")]
175
+
[DataRow(CliBool.False,"cosmosdb_nosql",DatabaseType.CosmosDB_NoSQL,DisplayName="Init command with '--graphql.nested-create.enabled false' for cosmosdb_nosql database type")]
176
+
[DataRow(CliBool.None,"cosmosdb_nosql",DatabaseType.CosmosDB_NoSQL,DisplayName="Init command without '--graphql.nested-create.enabled' option for cosmosdb_nosql database type")]
Assert.IsNull(runtimeConfig.Runtime.GraphQL.NestedMutationOptions,message:"NestedMutationOptions is expected to be null because a) DB type is not MsSQL or b) Either --graphql.nested-create.enabled option was not used or no value was provided.");
Copy file name to clipboardExpand all lines: src/Cli.Tests/InitTests.cs
+83Lines changed: 83 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -409,6 +409,89 @@ public Task GraphQLPathWithoutStartingSlashWillHaveItAdded()
409
409
returnExecuteVerifyTest(options);
410
410
}
411
411
412
+
/// <summary>
413
+
/// Test to validate the contents of the config file generated when init command is used with --graphql.nested-create.enabled flag option for different database types.
414
+
///
415
+
/// 1. For database types other than MsSQL:
416
+
/// - Irrespective of whether the --graphql.nested-create.enabled option is used or not, fields related to nested-create will NOT be written to the config file.
417
+
///
418
+
/// 2. For MsSQL database type:
419
+
/// a. When --graphql.nested-create.enabled option is used
420
+
/// - In this case, the fields related to nested mutation and nested create operations will be written to the config file.
421
+
/// "nested-mutations": {
422
+
/// "create": {
423
+
/// "enabled": true/false
424
+
/// }
425
+
/// }
426
+
///
427
+
/// b. When --graphql.nested-create.enabled option is not used
428
+
/// - In this case, fields related to nested mutation and nested create operations will NOT be written to the config file.
429
+
///
430
+
/// </summary>
431
+
[DataTestMethod]
432
+
[DataRow(DatabaseType.MSSQL,CliBool.True,DisplayName="Init command with '--graphql.nested-create.enabled true' for MsSQL database type")]
433
+
[DataRow(DatabaseType.MSSQL,CliBool.False,DisplayName="Init command with '--graphql.nested-create.enabled false' for MsSQL database type")]
434
+
[DataRow(DatabaseType.MSSQL,CliBool.None,DisplayName="Init command without '--graphql.nested-create.enabled' option for MsSQL database type")]
435
+
[DataRow(DatabaseType.PostgreSQL,CliBool.True,DisplayName="Init command with '--graphql.nested-create.enabled true' for PostgreSQL database type")]
436
+
[DataRow(DatabaseType.PostgreSQL,CliBool.False,DisplayName="Init command with '--graphql.nested-create.enabled false' for PostgreSQL database type")]
437
+
[DataRow(DatabaseType.PostgreSQL,CliBool.None,DisplayName="Init command without '--graphql.nested-create.enabled' option for PostgreSQL database type")]
438
+
[DataRow(DatabaseType.MySQL,CliBool.True,DisplayName="Init command with '--graphql.nested-create.enabled true' for MySQL database type")]
439
+
[DataRow(DatabaseType.MySQL,CliBool.False,DisplayName="Init command with '--graphql.nested-create.enabled false' for MySQL database type")]
440
+
[DataRow(DatabaseType.MySQL,CliBool.None,DisplayName="Init command without '--graphql.nested-create.enabled' option for MySQL database type")]
441
+
[DataRow(DatabaseType.CosmosDB_NoSQL,CliBool.True,DisplayName="Init command with '--graphql.nested-create.enabled true' for CosmosDB_NoSQL database type")]
442
+
[DataRow(DatabaseType.CosmosDB_NoSQL,CliBool.False,DisplayName="Init command with '--graphql.nested-create.enabled false' for CosmosDB_NoSQL database type")]
443
+
[DataRow(DatabaseType.CosmosDB_NoSQL,CliBool.None,DisplayName="Init command without '--graphql.nested-create.enabled' option for CosmosDB_NoSQL database type")]
444
+
[DataRow(DatabaseType.CosmosDB_PostgreSQL,CliBool.True,DisplayName="Init command with '--graphql.nested-create.enabled true' for CosmosDB_PostgreSQL database type")]
445
+
[DataRow(DatabaseType.CosmosDB_PostgreSQL,CliBool.False,DisplayName="Init command with '--graphql.nested-create.enabled false' for CosmosDB_PostgreSQL database type")]
446
+
[DataRow(DatabaseType.CosmosDB_PostgreSQL,CliBool.None,DisplayName="Init command without '--graphql.nested-create.enabled' option for CosmosDB_PostgreSQL database type")]
447
+
[DataRow(DatabaseType.DWSQL,CliBool.True,DisplayName="Init command with '--graphql.nested-create.enabled true' for DWSQL database type")]
448
+
[DataRow(DatabaseType.DWSQL,CliBool.False,DisplayName="Init command with '--graphql.nested-create.enabled false' for DWSQL database type")]
449
+
[DataRow(DatabaseType.DWSQL,CliBool.None,DisplayName="Init command without '--graphql.nested-create.enabled' option for DWSQL database type")]
0 commit comments