diff --git a/schemas/dab.draft.schema.json b/schemas/dab.draft.schema.json index 4159308c18..39bde040c0 100644 --- a/schemas/dab.draft.schema.json +++ b/schemas/dab.draft.schema.json @@ -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 } } diff --git a/src/Cli.Tests/EndToEndTests.cs b/src/Cli.Tests/EndToEndTests.cs index f15b744d36..4462f52c4d 100644 --- a/src/Cli.Tests/EndToEndTests.cs +++ b/src/Cli.Tests/EndToEndTests.cs @@ -132,49 +132,49 @@ public void TestInitializingRestAndGraphQLGlobalSettings() } /// - /// 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. /// /// - /// Value interpreted by the CLI for '--graphql.nested-create.enabled' option of the init command. + /// 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. /// - /// Expected value for the nested create enabled flag in the config file. + /// Expected value for the multiple create enabled flag in the config file. [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 args = new() { "init", "-c", TEST_RUNTIME_CONFIG_FILE, "--connection-string", SAMPLE_TEST_CONN_STRING, "--database-type", dbType }; @@ -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!); @@ -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."); } } diff --git a/src/Cli.Tests/InitTests.cs b/src/Cli.Tests/InitTests.cs index bfd0a7a19c..b8ea6bcb74 100644 --- a/src/Cli.Tests/InitTests.cs +++ b/src/Cli.Tests/InitTests.cs @@ -410,44 +410,44 @@ public Task GraphQLPathWithoutStartingSlashWillHaveItAdded() } /// - /// 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. + /// Test to validate the contents of the config file generated when init command is used with --graphql.multiple-create.enabled flag option for different database types. /// /// 1. 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. + /// - 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. /// /// 2. 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 /// } /// } /// - /// 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. + /// 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. /// /// [DataTestMethod] - [DataRow(DatabaseType.MSSQL, CliBool.True, DisplayName = "Init command with '--graphql.nested-create.enabled true' for MsSQL database type")] - [DataRow(DatabaseType.MSSQL, CliBool.False, DisplayName = "Init command with '--graphql.nested-create.enabled false' for MsSQL database type")] - [DataRow(DatabaseType.MSSQL, CliBool.None, DisplayName = "Init command without '--graphql.nested-create.enabled' option for MsSQL database type")] - [DataRow(DatabaseType.PostgreSQL, CliBool.True, DisplayName = "Init command with '--graphql.nested-create.enabled true' for PostgreSQL database type")] - [DataRow(DatabaseType.PostgreSQL, CliBool.False, DisplayName = "Init command with '--graphql.nested-create.enabled false' for PostgreSQL database type")] - [DataRow(DatabaseType.PostgreSQL, CliBool.None, DisplayName = "Init command without '--graphql.nested-create.enabled' option for PostgreSQL database type")] - [DataRow(DatabaseType.MySQL, CliBool.True, DisplayName = "Init command with '--graphql.nested-create.enabled true' for MySQL database type")] - [DataRow(DatabaseType.MySQL, CliBool.False, DisplayName = "Init command with '--graphql.nested-create.enabled false' for MySQL database type")] - [DataRow(DatabaseType.MySQL, CliBool.None, DisplayName = "Init command without '--graphql.nested-create.enabled' option for MySQL database type")] - [DataRow(DatabaseType.CosmosDB_NoSQL, CliBool.True, DisplayName = "Init command with '--graphql.nested-create.enabled true' for CosmosDB_NoSQL database type")] - [DataRow(DatabaseType.CosmosDB_NoSQL, CliBool.False, DisplayName = "Init command with '--graphql.nested-create.enabled false' for CosmosDB_NoSQL database type")] - [DataRow(DatabaseType.CosmosDB_NoSQL, CliBool.None, DisplayName = "Init command without '--graphql.nested-create.enabled' option for CosmosDB_NoSQL database type")] - [DataRow(DatabaseType.CosmosDB_PostgreSQL, CliBool.True, DisplayName = "Init command with '--graphql.nested-create.enabled true' for CosmosDB_PostgreSQL database type")] - [DataRow(DatabaseType.CosmosDB_PostgreSQL, CliBool.False, DisplayName = "Init command with '--graphql.nested-create.enabled false' for CosmosDB_PostgreSQL database type")] - [DataRow(DatabaseType.CosmosDB_PostgreSQL, CliBool.None, DisplayName = "Init command without '--graphql.nested-create.enabled' option for CosmosDB_PostgreSQL database type")] - [DataRow(DatabaseType.DWSQL, CliBool.True, DisplayName = "Init command with '--graphql.nested-create.enabled true' for DWSQL database type")] - [DataRow(DatabaseType.DWSQL, CliBool.False, DisplayName = "Init command with '--graphql.nested-create.enabled false' for DWSQL database type")] - [DataRow(DatabaseType.DWSQL, CliBool.None, DisplayName = "Init command without '--graphql.nested-create.enabled' option for DWSQL database type")] - public Task VerifyCorrectConfigGenerationWithNestedMutationOptions(DatabaseType databaseType, CliBool isNestedCreateEnabled) + [DataRow(DatabaseType.MSSQL, CliBool.True, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for MsSQL database type")] + [DataRow(DatabaseType.MSSQL, CliBool.False, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for MsSQL database type")] + [DataRow(DatabaseType.MSSQL, CliBool.None, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for MsSQL database type")] + [DataRow(DatabaseType.PostgreSQL, CliBool.True, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for PostgreSQL database type")] + [DataRow(DatabaseType.PostgreSQL, CliBool.False, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for PostgreSQL database type")] + [DataRow(DatabaseType.PostgreSQL, CliBool.None, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for PostgreSQL database type")] + [DataRow(DatabaseType.MySQL, CliBool.True, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for MySQL database type")] + [DataRow(DatabaseType.MySQL, CliBool.False, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for MySQL database type")] + [DataRow(DatabaseType.MySQL, CliBool.None, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for MySQL database type")] + [DataRow(DatabaseType.CosmosDB_NoSQL, CliBool.True, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for CosmosDB_NoSQL database type")] + [DataRow(DatabaseType.CosmosDB_NoSQL, CliBool.False, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for CosmosDB_NoSQL database type")] + [DataRow(DatabaseType.CosmosDB_NoSQL, CliBool.None, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for CosmosDB_NoSQL database type")] + [DataRow(DatabaseType.CosmosDB_PostgreSQL, CliBool.True, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for CosmosDB_PostgreSQL database type")] + [DataRow(DatabaseType.CosmosDB_PostgreSQL, CliBool.False, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for CosmosDB_PostgreSQL database type")] + [DataRow(DatabaseType.CosmosDB_PostgreSQL, CliBool.None, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for CosmosDB_PostgreSQL database type")] + [DataRow(DatabaseType.DWSQL, CliBool.True, DisplayName = "Init command with '--graphql.multiple-create.enabled true' for DWSQL database type")] + [DataRow(DatabaseType.DWSQL, CliBool.False, DisplayName = "Init command with '--graphql.multiple-create.enabled false' for DWSQL database type")] + [DataRow(DatabaseType.DWSQL, CliBool.None, DisplayName = "Init command without '--graphql.multiple-create.enabled' option for DWSQL database type")] + public Task VerifyCorrectConfigGenerationWithMultipleMutationOptions(DatabaseType databaseType, CliBool isMultipleCreateEnabled) { InitOptions options; @@ -468,7 +468,7 @@ public Task VerifyCorrectConfigGenerationWithNestedMutationOptions(DatabaseType authenticationProvider: EasyAuthType.StaticWebApps.ToString(), restPath: "rest-api", config: TEST_RUNTIME_CONFIG_FILE, - nestedCreateOperationEnabled: isNestedCreateEnabled); + multipleCreateOperationEnabled: isMultipleCreateEnabled); } else { @@ -484,11 +484,11 @@ public Task VerifyCorrectConfigGenerationWithNestedMutationOptions(DatabaseType authenticationProvider: EasyAuthType.StaticWebApps.ToString(), restPath: "rest-api", config: TEST_RUNTIME_CONFIG_FILE, - nestedCreateOperationEnabled: isNestedCreateEnabled); + multipleCreateOperationEnabled: isMultipleCreateEnabled); } VerifySettings verifySettings = new(); - verifySettings.UseHashedParameters(databaseType, isNestedCreateEnabled); + verifySettings.UseHashedParameters(databaseType, isMultipleCreateEnabled); return ExecuteVerifyTest(options, verifySettings); } diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_2be9ac1b7d981cde.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0546bef37027a950.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_2be9ac1b7d981cde.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0546bef37027a950.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_1211ad099a77f7c4.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0ac567dd32a2e8f5.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_1211ad099a77f7c4.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0ac567dd32a2e8f5.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_adc642ef89cb6d18.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0c06949221514e77.verified.txt similarity index 90% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_adc642ef89cb6d18.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0c06949221514e77.verified.txt index 65cf6b8748..62fc407842 100644 --- a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_adc642ef89cb6d18.verified.txt +++ b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_0c06949221514e77.verified.txt @@ -15,8 +15,8 @@ Enabled: true, Path: /graphql, AllowIntrospection: true, - NestedMutationOptions: { - NestedCreateOptions: { + MultipleMutationOptions: { + MultipleCreateOptions: { Enabled: false } } diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_215291b2b7ff2cb4.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_18667ab7db033e9d.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_215291b2b7ff2cb4.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_18667ab7db033e9d.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_92ba6ec2f08a3060.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_2f42f44c328eb020.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_92ba6ec2f08a3060.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_2f42f44c328eb020.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_7c4d5358dc16f63f.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_3243d3f3441fdcc1.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_7c4d5358dc16f63f.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_3243d3f3441fdcc1.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_1a73d3cfd329f922.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_53350b8b47df2112.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_1a73d3cfd329f922.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_53350b8b47df2112.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_09cf40a5c545de68.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_6584e0ec46b8a11d.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_09cf40a5c545de68.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_6584e0ec46b8a11d.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_17721ef496526b3e.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_81cc88db3d4eecfb.verified.txt similarity index 90% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_17721ef496526b3e.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_81cc88db3d4eecfb.verified.txt index 078169b766..be47d537b2 100644 --- a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_17721ef496526b3e.verified.txt +++ b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_81cc88db3d4eecfb.verified.txt @@ -15,8 +15,8 @@ Enabled: true, Path: /graphql, AllowIntrospection: true, - NestedMutationOptions: { - NestedCreateOptions: { + MultipleMutationOptions: { + MultipleCreateOptions: { Enabled: true } } diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_8459925dada37738.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_8ea187616dbb5577.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_8459925dada37738.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_8ea187616dbb5577.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_9efd9a8a0ff47434.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_905845c29560a3ef.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_9efd9a8a0ff47434.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_905845c29560a3ef.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_181195e2fbe991a8.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_b2fd24fab5b80917.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_181195e2fbe991a8.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_b2fd24fab5b80917.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_388c095980b1b53f.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_bd7cd088755287c9.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_388c095980b1b53f.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_bd7cd088755287c9.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_384e318d9ed21c9c.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d2eccba2f836b380.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_384e318d9ed21c9c.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d2eccba2f836b380.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_d1e814ccd5d8b8e8.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d463eed7fe5e4bbe.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_d1e814ccd5d8b8e8.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d463eed7fe5e4bbe.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_6fb51a691160163b.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d5520dd5c33f7b8d.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_6fb51a691160163b.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_d5520dd5c33f7b8d.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_c0ee0e6a86fa0b7e.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_eab4a6010e602b59.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_c0ee0e6a86fa0b7e.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_eab4a6010e602b59.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_ef2f00a9e204e114.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_ecaa688829b4030e.verified.txt similarity index 100% rename from src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_ef2f00a9e204e114.verified.txt rename to src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithMultipleMutationOptions_ecaa688829b4030e.verified.txt diff --git a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_35696f184b0ec6f0.verified.txt b/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_35696f184b0ec6f0.verified.txt deleted file mode 100644 index 794686467c..0000000000 --- a/src/Cli.Tests/Snapshots/InitTests.VerifyCorrectConfigGenerationWithNestedMutationOptions_35696f184b0ec6f0.verified.txt +++ /dev/null @@ -1,35 +0,0 @@ -{ - DataSource: { - DatabaseType: CosmosDB_PostgreSQL - }, - Runtime: { - Rest: { - Enabled: true, - Path: /rest-api, - RequestBodyStrict: true - }, - GraphQL: { - Enabled: true, - Path: /graphql, - AllowIntrospection: true, - NestedMutationOptions: { - NestedCreateOptions: { - Enabled: false - } - } - }, - Host: { - Cors: { - Origins: [ - http://localhost:3000, - http://nolocalhost:80 - ], - AllowCredentials: false - }, - Authentication: { - Provider: StaticWebApps - } - } - }, - Entities: [] -} \ No newline at end of file diff --git a/src/Cli/Commands/InitOptions.cs b/src/Cli/Commands/InitOptions.cs index a3d49d6bb1..67b8ef5b62 100644 --- a/src/Cli/Commands/InitOptions.cs +++ b/src/Cli/Commands/InitOptions.cs @@ -37,7 +37,7 @@ public InitOptions( CliBool restEnabled = CliBool.None, CliBool graphqlEnabled = CliBool.None, CliBool restRequestBodyStrict = CliBool.None, - CliBool nestedCreateOperationEnabled = CliBool.None, + CliBool multipleCreateOperationEnabled = CliBool.None, string? config = null) : base(config) { @@ -60,7 +60,7 @@ public InitOptions( RestEnabled = restEnabled; GraphQLEnabled = graphqlEnabled; RestRequestBodyStrict = restRequestBodyStrict; - NestedCreateOperationEnabled = nestedCreateOperationEnabled; + MultipleCreateOperationEnabled = multipleCreateOperationEnabled; } [Option("database-type", Required = true, HelpText = "Type of database to connect. Supported values: mssql, cosmosdb_nosql, cosmosdb_postgresql, mysql, postgresql, dwsql")] @@ -122,8 +122,8 @@ public InitOptions( [Option("rest.request-body-strict", Required = false, HelpText = "(Default: true) Allow extraneous fields in the request body for REST.")] public CliBool RestRequestBodyStrict { get; } - [Option("graphql.nested-create.enabled", Required = false, HelpText = "(Default: false) Enables nested create operation for GraphQL. Supported values: true, false.")] - public CliBool NestedCreateOperationEnabled { get; } + [Option("graphql.multiple-create.enabled", Required = false, HelpText = "(Default: false) Enables multiple create operation for GraphQL. Supported values: true, false.")] + public CliBool MultipleCreateOperationEnabled { get; } public void Handler(ILogger logger, FileSystemRuntimeConfigLoader loader, IFileSystem fileSystem) { diff --git a/src/Cli/ConfigGenerator.cs b/src/Cli/ConfigGenerator.cs index 4b819bf28d..8fe10e1749 100644 --- a/src/Cli/ConfigGenerator.cs +++ b/src/Cli/ConfigGenerator.cs @@ -113,25 +113,25 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime return false; } - bool isNestedCreateEnabledForGraphQL; + bool isMultipleCreateEnabledForGraphQL; - // Nested mutation operations are applicable only for MSSQL database. When the option --graphql.nested-create.enabled is specified for other database types, + // Multiple mutation operations are applicable only for MSSQL database. When the option --graphql.multiple-create.enabled is specified for other database types, // a warning is logged. - // When nested mutation operations are extended for other database types, this option should be honored. + // When multiple mutation operations are extended for other database types, this option should be honored. // Tracked by issue #2001: https://github.com/Azure/data-api-builder/issues/2001. - if (dbType is not DatabaseType.MSSQL && options.NestedCreateOperationEnabled is not CliBool.None) + if (dbType is not DatabaseType.MSSQL && options.MultipleCreateOperationEnabled is not CliBool.None) { - _logger.LogWarning($"The option --graphql.nested-create.enabled is not supported for the {dbType.ToString()} database type and will not be honored."); + _logger.LogWarning($"The option --graphql.multiple-create.enabled is not supported for the {dbType.ToString()} database type and will not be honored."); } - NestedMutationOptions? nestedMutationOptions = null; + MultipleMutationOptions? multipleMutationOptions = null; - // Nested mutation operations are applicable only for MSSQL database. When the option --graphql.nested-create.enabled is specified for other database types, + // Multiple mutation operations are applicable only for MSSQL database. When the option --graphql.multiple-create.enabled is specified for other database types, // it is not honored. - if (dbType is DatabaseType.MSSQL && options.NestedCreateOperationEnabled is not CliBool.None) + if (dbType is DatabaseType.MSSQL && options.MultipleCreateOperationEnabled is not CliBool.None) { - isNestedCreateEnabledForGraphQL = IsNestedCreateOperationEnabled(options.NestedCreateOperationEnabled); - nestedMutationOptions = new(nestedCreateOptions: new NestedCreateOptions(enabled: isNestedCreateEnabledForGraphQL)); + isMultipleCreateEnabledForGraphQL = IsMultipleCreateOperationEnabled(options.MultipleCreateOperationEnabled); + multipleMutationOptions = new(multipleCreateOptions: new MultipleCreateOptions(enabled: isMultipleCreateEnabledForGraphQL)); } switch (dbType) @@ -253,7 +253,7 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime DataSource: dataSource, Runtime: new( Rest: new(restEnabled, restPath ?? RestRuntimeOptions.DEFAULT_PATH, options.RestRequestBodyStrict is CliBool.False ? false : true), - GraphQL: new(Enabled: graphQLEnabled, Path: graphQLPath, NestedMutationOptions: nestedMutationOptions), + GraphQL: new(Enabled: graphQLEnabled, Path: graphQLPath, MultipleMutationOptions: multipleMutationOptions), Host: new( Cors: new(options.CorsOrigin?.ToArray() ?? Array.Empty()), Authentication: new( @@ -307,13 +307,13 @@ private static bool TryDetermineIfApiIsEnabled(bool apiDisabledOptionValue, CliB } /// - /// Helper method to determine if the nested create operation is enabled or not based on the inputs from dab init command. + /// Helper method to determine if the multiple create operation is enabled or not based on the inputs from dab init command. /// - /// Input value for --graphql.nested-create.enabled option of the init command + /// Input value for --graphql.multiple-create.enabled option of the init command /// True/False - private static bool IsNestedCreateOperationEnabled(CliBool nestedCreateEnabledOptionValue) + private static bool IsMultipleCreateOperationEnabled(CliBool multipleCreateEnabledOptionValue) { - return nestedCreateEnabledOptionValue is CliBool.True; + return multipleCreateEnabledOptionValue is CliBool.True; } /// diff --git a/src/Config/Converters/GraphQLRuntimeOptionsConverterFactory.cs b/src/Config/Converters/GraphQLRuntimeOptionsConverterFactory.cs index 0101cbba87..5f69531e9f 100644 --- a/src/Config/Converters/GraphQLRuntimeOptionsConverterFactory.cs +++ b/src/Config/Converters/GraphQLRuntimeOptionsConverterFactory.cs @@ -57,10 +57,10 @@ internal GraphQLRuntimeOptionsConverter(bool replaceEnvVar) if (reader.TokenType == JsonTokenType.StartObject) { - // Initialize with Nested Mutation operations disabled by default + // Initialize with Multiple Mutation operations disabled by default GraphQLRuntimeOptions graphQLRuntimeOptions = new(); - NestedMutationOptionsConverter nestedMutationOptionsConverter = options.GetConverter(typeof(NestedMutationOptions)) as NestedMutationOptionsConverter ?? - throw new JsonException("Failed to get nested mutation options converter"); + MultipleMutationOptionsConverter multipleMutationOptionsConverter = options.GetConverter(typeof(MultipleMutationOptions)) as MultipleMutationOptionsConverter ?? + throw new JsonException("Failed to get multiple mutation options converter"); while (reader.Read()) { @@ -121,8 +121,8 @@ internal GraphQLRuntimeOptionsConverter(bool replaceEnvVar) break; - case "nested-mutations": - graphQLRuntimeOptions = graphQLRuntimeOptions with { NestedMutationOptions = nestedMutationOptionsConverter.Read(ref reader, typeToConvert, options) }; + case "multiple-mutations": + graphQLRuntimeOptions = graphQLRuntimeOptions with { MultipleMutationOptions = multipleMutationOptionsConverter.Read(ref reader, typeToConvert, options) }; break; default: @@ -143,13 +143,13 @@ public override void Write(Utf8JsonWriter writer, GraphQLRuntimeOptions value, J writer.WriteString("path", value.Path); writer.WriteBoolean("allow-introspection", value.AllowIntrospection); - if (value.NestedMutationOptions is not null) + if (value.MultipleMutationOptions is not null) { - NestedMutationOptionsConverter nestedMutationOptionsConverter = options.GetConverter(typeof(NestedMutationOptions)) as NestedMutationOptionsConverter ?? - throw new JsonException("Failed to get nested mutation options converter"); + MultipleMutationOptionsConverter multipleMutationOptionsConverter = options.GetConverter(typeof(MultipleMutationOptions)) as MultipleMutationOptionsConverter ?? + throw new JsonException("Failed to get multiple mutation options converter"); - nestedMutationOptionsConverter.Write(writer, value.NestedMutationOptions, options); + multipleMutationOptionsConverter.Write(writer, value.MultipleMutationOptions, options); } writer.WriteEndObject(); diff --git a/src/Config/Converters/NestedCreateOptionsConverter.cs b/src/Config/Converters/MultipleCreateOptionsConverter.cs similarity index 76% rename from src/Config/Converters/NestedCreateOptionsConverter.cs rename to src/Config/Converters/MultipleCreateOptionsConverter.cs index 7e495ef303..5904b6b0c2 100644 --- a/src/Config/Converters/NestedCreateOptionsConverter.cs +++ b/src/Config/Converters/MultipleCreateOptionsConverter.cs @@ -8,12 +8,12 @@ namespace Azure.DataApiBuilder.Config.Converters { /// - /// Converter for the nested create operation options. + /// Converter for the multiple create operation options. /// - internal class NestedCreateOptionsConverter : JsonConverter + internal class MultipleCreateOptionsConverter : JsonConverter { /// - public override NestedCreateOptions? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override MultipleCreateOptions? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType == JsonTokenType.Null) { @@ -22,7 +22,7 @@ internal class NestedCreateOptionsConverter : JsonConverter if (reader.TokenType is JsonTokenType.StartObject) { - NestedCreateOptions? nestedCreateOptions = null; + MultipleCreateOptions? multipleCreateOptions = null; while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) @@ -43,7 +43,7 @@ internal class NestedCreateOptionsConverter : JsonConverter reader.Read(); if (reader.TokenType is JsonTokenType.True || reader.TokenType is JsonTokenType.False) { - nestedCreateOptions = new(reader.GetBoolean()); + multipleCreateOptions = new(reader.GetBoolean()); } break; @@ -52,14 +52,14 @@ internal class NestedCreateOptionsConverter : JsonConverter } } - return nestedCreateOptions; + return multipleCreateOptions; } - throw new JsonException("Failed to read the GraphQL Nested Create options"); + throw new JsonException("Failed to read the GraphQL Multiple Create options"); } /// - public override void Write(Utf8JsonWriter writer, NestedCreateOptions? value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, MultipleCreateOptions? value, JsonSerializerOptions options) { // If the value is null, it is not written to the config file. if (value is null) diff --git a/src/Config/Converters/NestedMutationOptionsConverter.cs b/src/Config/Converters/MultipleMutationOptionsConverter.cs similarity index 51% rename from src/Config/Converters/NestedMutationOptionsConverter.cs rename to src/Config/Converters/MultipleMutationOptionsConverter.cs index f121e070dd..fb943cad5b 100644 --- a/src/Config/Converters/NestedMutationOptionsConverter.cs +++ b/src/Config/Converters/MultipleMutationOptionsConverter.cs @@ -8,21 +8,21 @@ namespace Azure.DataApiBuilder.Config.Converters { /// - /// Converter for the nested mutation options. + /// Converter for the multiple mutation options. /// - internal class NestedMutationOptionsConverter : JsonConverter + internal class MultipleMutationOptionsConverter : JsonConverter { - private readonly NestedCreateOptionsConverter _nestedCreateOptionsConverter; + private readonly MultipleCreateOptionsConverter _multipleCreateOptionsConverter; - public NestedMutationOptionsConverter(JsonSerializerOptions options) + public MultipleMutationOptionsConverter(JsonSerializerOptions options) { - _nestedCreateOptionsConverter = options.GetConverter(typeof(NestedCreateOptions)) as NestedCreateOptionsConverter ?? - throw new JsonException("Failed to get nested create options converter"); + _multipleCreateOptionsConverter = options.GetConverter(typeof(MultipleCreateOptions)) as MultipleCreateOptionsConverter ?? + throw new JsonException("Failed to get multiple create options converter"); } /// - public override NestedMutationOptions? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override MultipleMutationOptions? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType == JsonTokenType.Null) { @@ -31,7 +31,7 @@ public NestedMutationOptionsConverter(JsonSerializerOptions options) if (reader.TokenType is JsonTokenType.StartObject) { - NestedMutationOptions? nestedMutationOptions = null; + MultipleMutationOptions? multipleMutationOptions = null; while (reader.Read()) { @@ -45,10 +45,10 @@ public NestedMutationOptionsConverter(JsonSerializerOptions options) { case "create": reader.Read(); - NestedCreateOptions? nestedCreateOptions = _nestedCreateOptionsConverter.Read(ref reader, typeToConvert, options); - if (nestedCreateOptions is not null) + MultipleCreateOptions? multipleCreateOptions = _multipleCreateOptionsConverter.Read(ref reader, typeToConvert, options); + if (multipleCreateOptions is not null) { - nestedMutationOptions = new(nestedCreateOptions); + multipleMutationOptions = new(multipleCreateOptions); } break; @@ -58,28 +58,28 @@ public NestedMutationOptionsConverter(JsonSerializerOptions options) } } - return nestedMutationOptions; + return multipleMutationOptions; } - throw new JsonException("Failed to read the GraphQL Nested Mutation options"); + throw new JsonException("Failed to read the GraphQL Multiple Mutation options"); } /// - public override void Write(Utf8JsonWriter writer, NestedMutationOptions? value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, MultipleMutationOptions? value, JsonSerializerOptions options) { - // If the nested mutation options is null, it is not written to the config file. + // If the multiple mutation options is null, it is not written to the config file. if (value is null) { return; } - writer.WritePropertyName("nested-mutations"); + writer.WritePropertyName("multiple-mutations"); writer.WriteStartObject(); - if (value.NestedCreateOptions is not null) + if (value.MultipleCreateOptions is not null) { - _nestedCreateOptionsConverter.Write(writer, value.NestedCreateOptions, options); + _multipleCreateOptionsConverter.Write(writer, value.MultipleCreateOptions, options); } writer.WriteEndObject(); diff --git a/src/Config/ObjectModel/GraphQLRuntimeOptions.cs b/src/Config/ObjectModel/GraphQLRuntimeOptions.cs index 9033d269e6..24d8533e43 100644 --- a/src/Config/ObjectModel/GraphQLRuntimeOptions.cs +++ b/src/Config/ObjectModel/GraphQLRuntimeOptions.cs @@ -6,7 +6,7 @@ namespace Azure.DataApiBuilder.Config.ObjectModel; public record GraphQLRuntimeOptions(bool Enabled = true, string Path = GraphQLRuntimeOptions.DEFAULT_PATH, bool AllowIntrospection = true, - NestedMutationOptions? NestedMutationOptions = null) + MultipleMutationOptions? MultipleMutationOptions = null) { public const string DEFAULT_PATH = "/graphql"; } diff --git a/src/Config/ObjectModel/MultipleCreateOptions.cs b/src/Config/ObjectModel/MultipleCreateOptions.cs new file mode 100644 index 0000000000..c4a566bf29 --- /dev/null +++ b/src/Config/ObjectModel/MultipleCreateOptions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +namespace Azure.DataApiBuilder.Config.ObjectModel; + +/// +/// Options for multiple create operations. +/// +/// Indicates whether multiple create operation is enabled. +public class MultipleCreateOptions +{ + /// + /// Indicates whether multiple create operation is enabled. + /// + public bool Enabled; + + public MultipleCreateOptions(bool enabled) + { + Enabled = enabled; + } +}; + diff --git a/src/Config/ObjectModel/MultipleMutationOptions.cs b/src/Config/ObjectModel/MultipleMutationOptions.cs new file mode 100644 index 0000000000..360b52a1f3 --- /dev/null +++ b/src/Config/ObjectModel/MultipleMutationOptions.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Azure.DataApiBuilder.Config.ObjectModel; + +/// +/// Class that holds the options for all multiple mutation operations. +/// +/// Options for multiple create operation. +public class MultipleMutationOptions +{ + // Options for multiple create operation. + public MultipleCreateOptions? MultipleCreateOptions; + + public MultipleMutationOptions(MultipleCreateOptions? multipleCreateOptions = null) + { + MultipleCreateOptions = multipleCreateOptions; + } + +} diff --git a/src/Config/ObjectModel/NestedCreateOptions.cs b/src/Config/ObjectModel/NestedCreateOptions.cs deleted file mode 100644 index 8439646766..0000000000 --- a/src/Config/ObjectModel/NestedCreateOptions.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -namespace Azure.DataApiBuilder.Config.ObjectModel; - -/// -/// Options for nested create operations. -/// -/// Indicates whether nested create operation is enabled. -public class NestedCreateOptions -{ - /// - /// Indicates whether nested create operation is enabled. - /// - public bool Enabled; - - public NestedCreateOptions(bool enabled) - { - Enabled = enabled; - } -}; - diff --git a/src/Config/ObjectModel/NestedMutationOptions.cs b/src/Config/ObjectModel/NestedMutationOptions.cs deleted file mode 100644 index 0cf6c05e3e..0000000000 --- a/src/Config/ObjectModel/NestedMutationOptions.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -namespace Azure.DataApiBuilder.Config.ObjectModel; - -/// -/// Class that holds the options for all nested mutation operations. -/// -/// Options for nested create operation. -public class NestedMutationOptions -{ - // Options for nested create operation. - public NestedCreateOptions? NestedCreateOptions; - - public NestedMutationOptions(NestedCreateOptions? nestedCreateOptions = null) - { - NestedCreateOptions = nestedCreateOptions; - } - - /// - /// Helper function that checks if nested create operation is enabled. - /// - /// True/False depending on whether nested create operation is enabled/disabled. - public bool IsNestedCreateOperationEnabled() - { - return NestedCreateOptions is not null && NestedCreateOptions.Enabled; - } - -} diff --git a/src/Config/RuntimeConfigLoader.cs b/src/Config/RuntimeConfigLoader.cs index a597d94f8d..f3c34b661a 100644 --- a/src/Config/RuntimeConfigLoader.cs +++ b/src/Config/RuntimeConfigLoader.cs @@ -171,8 +171,8 @@ public static JsonSerializerOptions GetSerializationOptions( options.Converters.Add(new EntityActionConverterFactory()); options.Converters.Add(new DataSourceFilesConverter()); options.Converters.Add(new EntityCacheOptionsConverterFactory()); - options.Converters.Add(new NestedCreateOptionsConverter()); - options.Converters.Add(new NestedMutationOptionsConverter(options)); + options.Converters.Add(new MultipleCreateOptionsConverter()); + options.Converters.Add(new MultipleMutationOptionsConverter(options)); options.Converters.Add(new DataSourceConverterFactory(replaceEnvVar)); if (replaceEnvVar) diff --git a/src/Service.Tests/Configuration/ConfigurationTests.cs b/src/Service.Tests/Configuration/ConfigurationTests.cs index ddf4a782e4..e6e955a098 100644 --- a/src/Service.Tests/Configuration/ConfigurationTests.cs +++ b/src/Service.Tests/Configuration/ConfigurationTests.cs @@ -1661,49 +1661,49 @@ public async Task TestSPRestDefaultsForManuallyConstructedConfigs( /// /// Validates that deserialization of config file is successful for the following scenarios: - /// 1. Nested Mutations section is null + /// 1. Multiple Mutations section is null /// { - /// "nested-mutations": null + /// "multiple-mutations": null /// } /// - /// 2. Nested Mutations section is empty. + /// 2. Multiple Mutations section is empty. /// { - /// "nested-mutations": {} + /// "multiple-mutations": {} /// } /// - /// 3. Create field within Nested Mutation section is null. + /// 3. Create field within Multiple Mutation section is null. /// { - /// "nested-mutations": { + /// "multiple-mutations": { /// "create": null /// } /// } /// - /// 4. Create field within Nested Mutation section is empty. + /// 4. Create field within Multiple Mutation section is empty. /// { - /// "nested-mutations": { + /// "multiple-mutations": { /// "create": {} /// } /// } /// - /// For all the above mentioned scenarios, the expected value for NestedMutationOptions field is null. + /// For all the above mentioned scenarios, the expected value for MultipleMutationOptions field is null. /// /// Base Config Json string. [DataTestMethod] - [DataRow(TestHelper.BASE_CONFIG_NULL_NESTED_MUTATIONS_FIELD, DisplayName = "NestedMutationOptions field deserialized as null when nested mutation section is null")] - [DataRow(TestHelper.BASE_CONFIG_EMPTY_NESTED_MUTATIONS_FIELD, DisplayName = "NestedMutationOptions field deserialized as null when nested mutation section is empty")] - [DataRow(TestHelper.BASE_CONFIG_NULL_NESTED_CREATE_FIELD, DisplayName = "NestedMutationOptions field deserialized as null when create field within nested mutation section is null")] - [DataRow(TestHelper.BASE_CONFIG_EMPTY_NESTED_CREATE_FIELD, DisplayName = "NestedMutationOptions field deserialized as null when create field within nested mutation section is empty")] - public void ValidateDeserializationOfConfigWithNullOrEmptyInvalidNestedMutationSection(string baseConfig) + [DataRow(TestHelper.BASE_CONFIG_NULL_MULTIPLE_MUTATIONS_FIELD, DisplayName = "MultipleMutationOptions field deserialized as null when multiple mutation section is null")] + [DataRow(TestHelper.BASE_CONFIG_EMPTY_MULTIPLE_MUTATIONS_FIELD, DisplayName = "MultipleMutationOptions field deserialized as null when multiple mutation section is empty")] + [DataRow(TestHelper.BASE_CONFIG_NULL_MULTIPLE_CREATE_FIELD, DisplayName = "MultipleMutationOptions field deserialized as null when create field within multiple mutation section is null")] + [DataRow(TestHelper.BASE_CONFIG_EMPTY_MULTIPLE_CREATE_FIELD, DisplayName = "MultipleMutationOptions field deserialized as null when create field within multiple mutation section is empty")] + public void ValidateDeserializationOfConfigWithNullOrEmptyInvalidMultipleMutationSection(string baseConfig) { string configJson = TestHelper.AddPropertiesToJson(baseConfig, BOOK_ENTITY_JSON); Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(configJson, out RuntimeConfig deserializedConfig)); Assert.IsNotNull(deserializedConfig.Runtime); Assert.IsNotNull(deserializedConfig.Runtime.GraphQL); - Assert.IsNull(deserializedConfig.Runtime.GraphQL.NestedMutationOptions); + Assert.IsNull(deserializedConfig.Runtime.GraphQL.MultipleMutationOptions); } /// - /// Sanity check to validate that DAB engine starts successfully when used with a config file without the nested + /// Sanity check to validate that DAB engine starts successfully when used with a config file without the multiple /// mutations feature flag section. /// The runtime graphql section of the config file used looks like this: /// @@ -1712,14 +1712,14 @@ public void ValidateDeserializationOfConfigWithNullOrEmptyInvalidNestedMutationS /// "allow-introspection": true /// } /// - /// Without the nested mutations feature flag section, DAB engine should be able to - /// 1. Successfully deserialize the config file without nested mutation section. + /// Without the multiple mutations feature flag section, DAB engine should be able to + /// 1. Successfully deserialize the config file without multiple mutation section. /// 2. Process REST and GraphQL API requests. /// /// [TestMethod] [TestCategory(TestCategory.MSSQL)] - public async Task SanityTestForRestAndGQLRequestsWithoutNestedMutationFeatureFlagSection() + public async Task SanityTestForRestAndGQLRequestsWithoutMultipleMutationFeatureFlagSection() { // The configuration file is constructed by merging hard-coded JSON strings to simulate the scenario where users manually edit the // configuration file (instead of using CLI). diff --git a/src/Service.Tests/Multidab-config.MsSql.json b/src/Service.Tests/Multidab-config.MsSql.json index 9f05161a83..a428c0a27b 100644 --- a/src/Service.Tests/Multidab-config.MsSql.json +++ b/src/Service.Tests/Multidab-config.MsSql.json @@ -16,7 +16,7 @@ "enabled": true, "path": "/graphql", "allow-introspection": true, - "nested-mutations": { + "multiple-mutations": { "create": { "enabled": true } diff --git a/src/Service.Tests/TestHelper.cs b/src/Service.Tests/TestHelper.cs index 466ca311ef..a8d152651c 100644 --- a/src/Service.Tests/TestHelper.cs +++ b/src/Service.Tests/TestHelper.cs @@ -237,47 +237,47 @@ public static RuntimeConfig AddMissingEntitiesToConfig(RuntimeConfig config, str "}"; /// - /// A minimal valid config json with nested mutations section as null. + /// A minimal valid config json with multiple mutations section as null. /// - public const string BASE_CONFIG_NULL_NESTED_MUTATIONS_FIELD = + public const string BASE_CONFIG_NULL_MULTIPLE_MUTATIONS_FIELD = RUNTIME_REST_GRAPHQL_OPTIONS_CONFIG_JSON + @" - ""nested-mutations"": null + ""multiple-mutations"": null }," + HOST_AND_ENTITY_OPTIONS_CONFIG_JSON; /// - /// A minimal valid config json with an empty nested mutations section. + /// A minimal valid config json with an empty multiple mutations section. /// - public const string BASE_CONFIG_EMPTY_NESTED_MUTATIONS_FIELD = + public const string BASE_CONFIG_EMPTY_MULTIPLE_MUTATIONS_FIELD = RUNTIME_REST_GRAPHQL_OPTIONS_CONFIG_JSON + @" - ""nested-mutations"": {} + ""multiple-mutations"": {} }," + HOST_AND_ENTITY_OPTIONS_CONFIG_JSON; /// - /// A minimal valid config json with the create field within nested mutation as null. + /// A minimal valid config json with the create field within multiple mutation as null. /// - public const string BASE_CONFIG_NULL_NESTED_CREATE_FIELD = + public const string BASE_CONFIG_NULL_MULTIPLE_CREATE_FIELD = RUNTIME_REST_GRAPHQL_OPTIONS_CONFIG_JSON + @" - ""nested-mutations"": { + ""multiple-mutations"": { ""create"": null } }," + HOST_AND_ENTITY_OPTIONS_CONFIG_JSON; /// - /// A minimal valid config json with an empty create field within nested mutation. + /// A minimal valid config json with an empty create field within multiple mutation. /// - public const string BASE_CONFIG_EMPTY_NESTED_CREATE_FIELD = + public const string BASE_CONFIG_EMPTY_MULTIPLE_CREATE_FIELD = RUNTIME_REST_GRAPHQL_OPTIONS_CONFIG_JSON + @" - ""nested-mutations"": { + ""multiple-mutations"": { ""create"": {} } }," + diff --git a/src/Service.Tests/Unittests/RuntimeConfigLoaderJsonDeserializerTests.cs b/src/Service.Tests/Unittests/RuntimeConfigLoaderJsonDeserializerTests.cs index 2f950b20d0..0d754263bb 100644 --- a/src/Service.Tests/Unittests/RuntimeConfigLoaderJsonDeserializerTests.cs +++ b/src/Service.Tests/Unittests/RuntimeConfigLoaderJsonDeserializerTests.cs @@ -423,7 +423,7 @@ public static string GetModifiedJsonString(string[] reps, string enumString) ""enabled"": true, ""path"": """ + reps[++index % reps.Length] + @""", ""allow-introspection"": true, - ""nested-mutations"": { + ""multiple-mutations"": { ""create"": { ""enabled"": false } diff --git a/src/Service.Tests/dab-config.MsSql.json b/src/Service.Tests/dab-config.MsSql.json index 0453d1ecf1..be8a96d2c3 100644 --- a/src/Service.Tests/dab-config.MsSql.json +++ b/src/Service.Tests/dab-config.MsSql.json @@ -17,7 +17,7 @@ "enabled": true, "path": "/graphql", "allow-introspection": true, - "nested-mutations": { + "multiple-mutations": { "create": { "enabled": true }