Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Cli/src/ConfigGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public static bool TryCreateRuntimeConfig(InitOptions options, out string runtim
RuntimeConfig runtimeConfig = new(
Schema: RuntimeConfig.SCHEMA,
DataSource: dataSource,
CosmosDb: cosmosDbNoSqlOptions,
RuntimeSettings: GetDefaultGlobalSettings(
options.HostMode,
options.CorsOrigin,
Expand Down
5 changes: 0 additions & 5 deletions src/Cli/test/InitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ public void CosmosDbNoSqlDatabase()
""schema"": ""schemafile""
}
},
""cosmos"": {
""database"": ""testdb"",
""container"": ""testcontainer"",
""schema"": ""schemafile""
},
""entities"": {}
}";

Expand Down
4 changes: 0 additions & 4 deletions src/Config/DataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ public record CosmosDbOptions(
string? GraphQLSchema)
{
public const string GRAPHQL_SCHEMA_PATH_PROPERTY_NAME = "schema";

// Keeping the name as cosmos only to provide backwards compatibility.
// This property won't be needed going forward.
public const string JSON_PROPERTY_NAME = nameof(DatabaseType.cosmos);
}

/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions src/Config/RuntimeConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public record RuntimeConfig(
[property: JsonPropertyName(GlobalSettings.JSON_PROPERTY_NAME)]
Dictionary<GlobalSettingsType, object>? RuntimeSettings,
[property: JsonPropertyName(Entity.JSON_PROPERTY_NAME)]
Dictionary<string, Entity> Entities,
[property: JsonPropertyName(CosmosDbOptions.JSON_PROPERTY_NAME)]
CosmosDbOptions? CosmosDb = null)
Dictionary<string, Entity> Entities)
{
public const string SCHEMA_PROPERTY_NAME = "$schema";
public const string SCHEMA = "dab.draft.schema.json";
Expand Down
2 changes: 1 addition & 1 deletion src/Service.Tests/Configuration/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public async Task TestSettingConfigurationCreatesCorrectClasses()
Assert.IsTrue(isConfigSet, "TryGetRuntimeConfiguration should return true when the config is set.");

Assert.AreEqual(DatabaseType.cosmos, configuration.DatabaseType, "Expected cosmos database type after configuring the runtime with cosmos settings.");
Assert.AreEqual(config.Schema, configuration.CosmosDb.GraphQLSchema, "Expected the schema in the configuration to match the one sent to the configuration endpoint.");
Assert.AreEqual(config.Schema, configuration.DataSource.CosmosDbNoSql.GraphQLSchema, "Expected the schema in the configuration to match the one sent to the configuration endpoint.");
Assert.AreEqual(config.ConnectionString, configuration.ConnectionString, "Expected the connection string in the configuration to match the one sent to the configuration endpoint.");
}

Expand Down
5 changes: 3 additions & 2 deletions src/Service/Configurations/RuntimeConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ public void Initialize(
throw new ArgumentException($"'{nameof(schema)}' cannot be null or empty.", nameof(schema));
}

CosmosDbOptions? cosmosDb = RuntimeConfiguration.CosmosDb! with { GraphQLSchema = schema };
RuntimeConfiguration = RuntimeConfiguration with { CosmosDb = cosmosDb };
CosmosDbOptions? cosmosDb = RuntimeConfiguration.DataSource.CosmosDbNoSql! with { GraphQLSchema = schema };
DataSource dataSource = RuntimeConfiguration.DataSource with { CosmosDbNoSql = cosmosDb };
RuntimeConfiguration = RuntimeConfiguration with { DataSource = dataSource };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public CosmosSqlMetadataProvider(RuntimeConfigProvider runtimeConfigProvider, IF
_databaseType = _runtimeConfig.DatabaseType;
_graphQLSingularTypeToEntityNameMap = _runtimeConfig.GraphQLSingularTypeToEntityNameMap;

CosmosDbOptions? cosmosDb = _runtimeConfig.CosmosDb;
CosmosDbOptions? cosmosDb = _runtimeConfig.DataSource.CosmosDbNoSql;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this section looks like it could be simplified. the conditional could just check _runtimeConfig.DataSource.CosmosDbNoSql for null and assign that value to _cosmosDb if not null.


if (cosmosDb is null)
{
Expand Down