Skip to content

Commit 8e8ffc3

Browse files
authored
Merge branch 'main' into mbhaskar/pagination-support
2 parents 19b487f + 9835a14 commit 8e8ffc3

File tree

10 files changed

+32
-30
lines changed

10 files changed

+32
-30
lines changed

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service.Tests/TestHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static IOptions<DataGatewayConfig> LoadConfig()
6161
.AddJsonFile("appsettings.Test.json")
6262
.Build();
6363

64-
config.Bind("DatabaseConnection", datagatewayConfig);
64+
config.Bind(nameof(DataGatewayConfig), datagatewayConfig);
6565

6666
return Options.Create(datagatewayConfig);
6767
}

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/.vscode/launch.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"name": ".NET Core Launch (web)",
1212
"type": "coreclr",
1313
"request": "launch",
14+
"justMyCode": false,
1415
"preLaunchTask": "build",
1516
// If you have changed target frameworks, make sure to update the program path.
1617
"program": "${workspaceFolder}/bin/Debug/net5.0/Cosmos.GraphQL.Service.dll",
@@ -37,6 +38,7 @@
3738
"name": ".NET Core Launch (PostgreSql)",
3839
"type": "coreclr",
3940
"request": "launch",
41+
"justMyCode": false,
4042
"preLaunchTask": "build",
4143
// If you have changed target frameworks, make sure to update the program path.
4244
"program": "${workspaceFolder}/bin/Debug/net5.0/Cosmos.GraphQL.Service.dll",
@@ -59,7 +61,8 @@
5961
{
6062
"name": ".NET Core Attach",
6163
"type": "coreclr",
62-
"request": "attach"
64+
"request": "attach",
65+
"justMyCode": false
6366
}
6467
]
6568
}

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/Resolvers/CosmosClientProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class CosmosClientProvider
1111

1212
public CosmosClientProvider(IOptions<DataGatewayConfig> dataGatewayConfig)
1313
{
14-
_cosmosClient = new CosmosClientBuilder(dataGatewayConfig.Value.Credentials.ConnectionString).WithContentResponseOnWrite(true).Build();
14+
_cosmosClient = new CosmosClientBuilder(dataGatewayConfig.Value.DatabaseConnection.ConnectionString).WithContentResponseOnWrite(true).Build();
1515
}
1616

1717
public CosmosClient GetClient()

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/Resolvers/QueryExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public QueryExecutor(IOptions<DataGatewayConfig> dataGatewayConfig)
3030
public async Task<DbDataReader> ExecuteQueryAsync(string sqltext, IDictionary<string, object> parameters)
3131
{
3232
var conn = new ConnectionT();
33-
conn.ConnectionString = _datagatewayConfig.Credentials.ConnectionString;
33+
conn.ConnectionString = _datagatewayConfig.DatabaseConnection.ConnectionString;
3434
await conn.OpenAsync();
3535
DbCommand cmd = conn.CreateCommand();
3636
cmd.CommandText = sqltext;

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/Startup.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ public Startup(IConfiguration configuration)
2626
// This method gets called by the runtime. Use this method to add services to the container.
2727
public void ConfigureServices(IServiceCollection services)
2828
{
29-
services.Configure<DataGatewayConfig>(Configuration.GetSection("DatabaseConnection"));
29+
services.Configure<DataGatewayConfig>(Configuration.GetSection(nameof(DataGatewayConfig)));
3030
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<DataGatewayConfig>, DataGatewayConfigPostConfiguration>());
3131
services.TryAddEnumerable(ServiceDescriptor.Singleton<IValidateOptions<DataGatewayConfig>, DataGatewayConfigValidation>());
3232

3333
// Read configuration and use it locally.
3434
DataGatewayConfig dataGatewayConfig = new DataGatewayConfig();
35-
// Need to rename DatabaseConnection to DataGatewayConfig in the CI pipeline.
36-
Configuration.Bind("DatabaseConnection", dataGatewayConfig);
35+
Configuration.Bind(nameof(DataGatewayConfig), dataGatewayConfig);
3736

3837
switch (dataGatewayConfig.DatabaseType)
3938
{

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/appsettings.MsSql.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"DatabaseConnection": {
2+
"DataGatewayConfig": {
33
"DatabaseType": "MsSql",
44
"ResolverConfigFile": "mssql-config.json",
5-
"Credentials": {
5+
"DatabaseConnection": {
66
"Server": "localhost",
77
"DatabaseName": "graphql",
88
"ConnectionString": "Server=tcp:127.0.0.1,1433;Persist Security Info=False;User ID=sa;Password=REPLACEME;MultipleActiveResultSets=False;Connection Timeout=5;"

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/appsettings.PostgreSql.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"DatabaseConnection": {
2+
"DataGatewayConfig": {
33
"DatabaseType": "PostgreSql",
44
"ResolverConfigFile": "postgresql-config.json",
5-
"Credentials": {
5+
"DatabaseConnection": {
66
"ConnectionString": "Host=localhost;Database=graphql"
77
}
88
}

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/appsettings.Test.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
}
88
},
99
"AllowedHosts": "*",
10-
"DatabaseConnection": {
10+
"DataGatewayConfig": {
1111
"DatabaseType": "MsSql",
12-
"Credentials": {
12+
"DatabaseConnection": {
1313
"ConnectionString": "Server=tcp:127.0.0.1,1433;Persist Security Info=False;User ID=sa;Password=REPLACEME;MultipleActiveResultSets=False;Connection Timeout=5;"
1414
}
1515
}

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/appsettings.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
}
88
},
99
"AllowedHosts": "*",
10-
"DatabaseConnection": {
10+
"DataGatewayConfig": {
1111
"DatabaseType": "",
12-
"Credentials": {
13-
"ServerEndpointUrl": "",
14-
"AuthorizationKey": "",
15-
"Server": "",
16-
"Database": "",
17-
"Container": "",
18-
"ConnectionString": ""
12+
"DatabaseConnection": {
13+
"ServerEndpointUrl": "",
14+
"AuthorizationKey": "",
15+
"Server": "",
16+
"Database": "",
17+
"Container": "",
18+
"ConnectionString": ""
1919
}
2020
}
2121
}

Cosmos.GraphQL.Service/Cosmos.GraphQL.Service/configurations/ConfigurationProvider.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class DataGatewayConfig
3939
public DatabaseType DatabaseType { get; set; }
4040

4141
// This should be renamed to databaseConnection but need to coordiate with moderakh on CI configuration.
42-
public DatabaseConnectionConfig Credentials { get; set; }
42+
public DatabaseConnectionConfig DatabaseConnection { get; set; }
4343
public string ResolverConfigFile { get; set; } = "config.json";
4444
}
4545

@@ -67,9 +67,9 @@ public class DataGatewayConfigPostConfiguration : IPostConfigureOptions<DataGate
6767
{
6868
public void PostConfigure(string name, DataGatewayConfig options)
6969
{
70-
bool connStringProvided = !string.IsNullOrEmpty(options.Credentials.ConnectionString);
71-
bool serverProvided = !string.IsNullOrEmpty(options.Credentials.Server);
72-
bool dbNameProvided = !string.IsNullOrEmpty(options.Credentials.Database);
70+
bool connStringProvided = !string.IsNullOrEmpty(options.DatabaseConnection.ConnectionString);
71+
bool serverProvided = !string.IsNullOrEmpty(options.DatabaseConnection.Server);
72+
bool dbNameProvided = !string.IsNullOrEmpty(options.DatabaseConnection.Database);
7373

7474
if (!connStringProvided && !serverProvided && !dbNameProvided)
7575
{
@@ -80,7 +80,7 @@ public void PostConfigure(string name, DataGatewayConfig options)
8080
throw new NotSupportedException("Either Server and DatabaseName or ConnectionString need to be provided, not both");
8181
}
8282

83-
if (string.IsNullOrWhiteSpace(options.Credentials.ConnectionString))
83+
if (string.IsNullOrWhiteSpace(options.DatabaseConnection.ConnectionString))
8484
{
8585
if ((!serverProvided && dbNameProvided) || (serverProvided && !dbNameProvided))
8686
{
@@ -89,12 +89,12 @@ public void PostConfigure(string name, DataGatewayConfig options)
8989

9090
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder
9191
{
92-
InitialCatalog = options.Credentials.Database,
93-
DataSource = options.Credentials.Server,
92+
InitialCatalog = options.DatabaseConnection.Database,
93+
DataSource = options.DatabaseConnection.Server,
9494
};
9595

9696
builder.IntegratedSecurity = true;
97-
options.Credentials.ConnectionString = builder.ToString();
97+
options.DatabaseConnection.ConnectionString = builder.ToString();
9898
}
9999
}
100100
}
@@ -108,7 +108,7 @@ public class DataGatewayConfigValidation : IValidateOptions<DataGatewayConfig>
108108
{
109109
public ValidateOptionsResult Validate(string name, DataGatewayConfig options)
110110
{
111-
return string.IsNullOrWhiteSpace(options.Credentials.ConnectionString)
111+
return string.IsNullOrWhiteSpace(options.DatabaseConnection.ConnectionString)
112112
? ValidateOptionsResult.Fail("Invalid connection string.")
113113
: ValidateOptionsResult.Success;
114114
}

0 commit comments

Comments
 (0)