Skip to content

Commit

Permalink
Rename nested-mutations and nested-create to multiple-mutations and m…
Browse files Browse the repository at this point in the history
…ultiple-create respectively (#2103)

## Why make this change?

-  Closes #2090
- Renames `nested-mutations` and `nested-create` to `multiple-mutations`
and `multiple-create` respectively.
- Nested Mutations has a significantly different meaning in the graphql
specs (as explained in issue
graphql/graphql-spec#252) compared to what we
are trying to achieve. Hence, the decision to rename.

## What is this change?

- All references to nested mutations/nested create - option name, field
names in config JSON, class names, comments in code have been renamed.

## How was this tested?

- Unit and Integration tests added as part of
#1983 has been updated to
validate the rename of CLI option, property in the config file, etc.

## Sample Commands


![image](https://github.com/Azure/data-api-builder/assets/11196553/7815bdb8-b0ca-409c-9b28-1101d5639130)
  • Loading branch information
severussundar committed Mar 20, 2024
1 parent db967d5 commit b1d5aca
Show file tree
Hide file tree
Showing 38 changed files with 206 additions and 250 deletions.
8 changes: 4 additions & 4 deletions schemas/dab.draft.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,19 @@
"type": "boolean",
"description": "Allow enabling/disabling GraphQL requests for all entities."
},
"nested-mutations": {
"multiple-mutations": {
"type": "object",
"description": "Configuration properties for nested mutation operations",
"description": "Configuration properties for multiple mutation operations",
"additionalProperties": false,
"properties": {
"create":{
"type": "object",
"description": "Options for nested create operations",
"description": "Options for multiple create operations",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"description": "Allow enabling/disabling nested create operations for all entities.",
"description": "Allow enabling/disabling multiple create operations for all entities.",
"default": false
}
}
Expand Down
74 changes: 37 additions & 37 deletions src/Cli.Tests/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,49 +132,49 @@ public void TestInitializingRestAndGraphQLGlobalSettings()
}

/// <summary>
/// Test to validate the usage of --graphql.nested-create.enabled option of the init command for all database types.
/// Test to validate the usage of --graphql.multiple-create.enabled option of the init command for all database types.
///
/// 1. Behavior for database types other than MsSQL:
/// - 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.
/// - As a result, after deserialization of such a config file, the Runtime.GraphQL.NestedMutationOptions is expected to be null.
/// - Irrespective of whether the --graphql.multiple-create.enabled option is used or not, fields related to multiple-create will NOT be written to the config file.
/// - As a result, after deserialization of such a config file, the Runtime.GraphQL.MultipleMutationOptions is expected to be null.
/// 2. Behavior for MsSQL database type:
///
/// a. When --graphql.nested-create.enabled option is used
/// - In this case, the fields related to nested mutation and nested create operations will be written to the config file.
/// "nested-mutations": {
/// a. When --graphql.multiple-create.enabled option is used
/// - In this case, the fields related to multiple mutation and multiple create operations will be written to the config file.
/// "multiple-mutations": {
/// "create": {
/// "enabled": true/false
/// }
/// }
/// 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.
/// After deserializing such a config file, the Runtime.GraphQL.MultipleMutationOptions 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.
///
/// b. When --graphql.nested-create.enabled option is not used
/// - In this case, fields related to nested mutation and nested create operations will NOT be written to the config file.
/// - As a result, after deserialization of such a config file, the Runtime.GraphQL.NestedMutationOptions is expected to be null.
/// b. When --graphql.multiple-create.enabled option is not used
/// - In this case, fields related to multiple mutation and multiple create operations will NOT be written to the config file.
/// - As a result, after deserialization of such a config file, the Runtime.GraphQL.MultipleMutationOptions is expected to be null.
///
/// </summary>
/// <param name="isNestedCreateEnabled">Value interpreted by the CLI for '--graphql.nested-create.enabled' option of the init command.
/// <param name="isMultipleCreateEnabled">Value interpreted by the CLI for '--graphql.multiple-create.enabled' option of the init command.
/// When not used, CLI interprets the value for the option as CliBool.None
/// When used with true/false, CLI interprets the value as CliBool.True/CliBool.False respectively.
/// </param>
/// <param name="expectedValueForNestedCreateEnabledFlag"> Expected value for the nested create enabled flag in the config file.</param>
/// <param name="expectedValueForMultipleCreateEnabledFlag"> Expected value for the multiple create enabled flag in the config file.</param>
[DataTestMethod]
[DataRow(CliBool.True, "mssql", DatabaseType.MSSQL, DisplayName = "Init command with '--graphql.nested-create.enabled true' for MsSql database type")]
[DataRow(CliBool.False, "mssql", DatabaseType.MSSQL, DisplayName = "Init command with '--graphql.nested-create.enabled false' for MsSql database type")]
[DataRow(CliBool.None, "mssql", DatabaseType.MSSQL, DisplayName = "Init command without '--graphql.nested-create.enabled' option for MsSql database type")]
[DataRow(CliBool.True, "mysql", DatabaseType.MySQL, DisplayName = "Init command with '--graphql.nested-create.enabled true' for MySql database type")]
[DataRow(CliBool.False, "mysql", DatabaseType.MySQL, DisplayName = "Init command with '--graphql.nested-create.enabled false' for MySql database type")]
[DataRow(CliBool.None, "mysql", DatabaseType.MySQL, DisplayName = "Init command without '--graphql.nested-create.enabled' option for MySql database type")]
[DataRow(CliBool.True, "postgresql", DatabaseType.PostgreSQL, DisplayName = "Init command with '--graphql.nested-create.enabled true' for PostgreSql database type")]
[DataRow(CliBool.False, "postgresql", DatabaseType.PostgreSQL, DisplayName = "Init command with '--graphql.nested-create.enabled false' for PostgreSql database type")]
[DataRow(CliBool.None, "postgresql", DatabaseType.PostgreSQL, DisplayName = "Init command without '--graphql.nested-create.enabled' option for PostgreSql database type")]
[DataRow(CliBool.True, "dwsql", DatabaseType.DWSQL, DisplayName = "Init command with '--graphql.nested-create.enabled true' for dwsql database type")]
[DataRow(CliBool.False, "dwsql", DatabaseType.DWSQL, DisplayName = "Init command with '--graphql.nested-create.enabled false' for dwsql database type")]
[DataRow(CliBool.None, "dwsql", DatabaseType.DWSQL, DisplayName = "Init command without '--graphql.nested-create.enabled' option for dwsql database type")]
[DataRow(CliBool.True, "cosmosdb_nosql", DatabaseType.CosmosDB_NoSQL, DisplayName = "Init command with '--graphql.nested-create.enabled true' for cosmosdb_nosql database type")]
[DataRow(CliBool.False, "cosmosdb_nosql", DatabaseType.CosmosDB_NoSQL, DisplayName = "Init command with '--graphql.nested-create.enabled false' for cosmosdb_nosql database type")]
[DataRow(CliBool.None, "cosmosdb_nosql", DatabaseType.CosmosDB_NoSQL, DisplayName = "Init command without '--graphql.nested-create.enabled' option for cosmosdb_nosql database type")]
public void TestEnablingNestedCreateOperation(CliBool isNestedCreateEnabled, string dbType, DatabaseType expectedDbType)
[DataRow(CliBool.True, "mssql", DatabaseType.MSSQL, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for MsSql database type")]
[DataRow(CliBool.False, "mssql", DatabaseType.MSSQL, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for MsSql database type")]
[DataRow(CliBool.None, "mssql", DatabaseType.MSSQL, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for MsSql database type")]
[DataRow(CliBool.True, "mysql", DatabaseType.MySQL, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for MySql database type")]
[DataRow(CliBool.False, "mysql", DatabaseType.MySQL, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for MySql database type")]
[DataRow(CliBool.None, "mysql", DatabaseType.MySQL, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for MySql database type")]
[DataRow(CliBool.True, "postgresql", DatabaseType.PostgreSQL, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for PostgreSql database type")]
[DataRow(CliBool.False, "postgresql", DatabaseType.PostgreSQL, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for PostgreSql database type")]
[DataRow(CliBool.None, "postgresql", DatabaseType.PostgreSQL, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for PostgreSql database type")]
[DataRow(CliBool.True, "dwsql", DatabaseType.DWSQL, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for dwsql database type")]
[DataRow(CliBool.False, "dwsql", DatabaseType.DWSQL, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for dwsql database type")]
[DataRow(CliBool.None, "dwsql", DatabaseType.DWSQL, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for dwsql database type")]
[DataRow(CliBool.True, "cosmosdb_nosql", DatabaseType.CosmosDB_NoSQL, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for cosmosdb_nosql database type")]
[DataRow(CliBool.False, "cosmosdb_nosql", DatabaseType.CosmosDB_NoSQL, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for cosmosdb_nosql database type")]
[DataRow(CliBool.None, "cosmosdb_nosql", DatabaseType.CosmosDB_NoSQL, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for cosmosdb_nosql database type")]
public void TestEnablingMultipleCreateOperation(CliBool isMultipleCreateEnabled, string dbType, DatabaseType expectedDbType)
{
List<string> args = new() { "init", "-c", TEST_RUNTIME_CONFIG_FILE, "--connection-string", SAMPLE_TEST_CONN_STRING, "--database-type", dbType };

Expand All @@ -185,10 +185,10 @@ public void TestEnablingNestedCreateOperation(CliBool isNestedCreateEnabled, str
args.AddRange(cosmosNoSqlArgs);
}

if (isNestedCreateEnabled is not CliBool.None)
if (isMultipleCreateEnabled is not CliBool.None)
{
args.Add("--graphql.nested-create.enabled");
args.Add(isNestedCreateEnabled.ToString()!);
args.Add("--graphql.multiple-create.enabled");
args.Add(isMultipleCreateEnabled.ToString()!);
}

Program.Execute(args.ToArray(), _cliLogger!, _fileSystem!, _runtimeConfigLoader!);
Expand All @@ -202,16 +202,16 @@ public void TestEnablingNestedCreateOperation(CliBool isNestedCreateEnabled, str
Assert.AreEqual(expectedDbType, runtimeConfig.DataSource.DatabaseType);
Assert.IsNotNull(runtimeConfig.Runtime);
Assert.IsNotNull(runtimeConfig.Runtime.GraphQL);
if (runtimeConfig.DataSource.DatabaseType is DatabaseType.MSSQL && isNestedCreateEnabled is not CliBool.None)
if (runtimeConfig.DataSource.DatabaseType is DatabaseType.MSSQL && isMultipleCreateEnabled is not CliBool.None)
{
Assert.IsNotNull(runtimeConfig.Runtime.GraphQL.NestedMutationOptions);
Assert.IsNotNull(runtimeConfig.Runtime.GraphQL.NestedMutationOptions.NestedCreateOptions);
bool expectedValueForNestedCreateEnabled = isNestedCreateEnabled == CliBool.True;
Assert.AreEqual(expectedValueForNestedCreateEnabled, runtimeConfig.Runtime.GraphQL.NestedMutationOptions.NestedCreateOptions.Enabled);
Assert.IsNotNull(runtimeConfig.Runtime.GraphQL.MultipleMutationOptions);
Assert.IsNotNull(runtimeConfig.Runtime.GraphQL.MultipleMutationOptions.MultipleCreateOptions);
bool expectedValueForMultipleCreateEnabled = isMultipleCreateEnabled == CliBool.True;
Assert.AreEqual(expectedValueForMultipleCreateEnabled, runtimeConfig.Runtime.GraphQL.MultipleMutationOptions.MultipleCreateOptions.Enabled);
}
else
{
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.");
Assert.IsNull(runtimeConfig.Runtime.GraphQL.MultipleMutationOptions, message: "MultipleMutationOptions is expected to be null because a) DB type is not MsSQL or b) Either --graphql.multiple-create.enabled option was not used or no value was provided.");
}
}

Expand Down
Loading

0 comments on commit b1d5aca

Please sign in to comment.