From e4adb69a6f7667db6cb32b8b8e6b3fc76bb82e95 Mon Sep 17 00:00:00 2001 From: aaron burtle Date: Tue, 1 Nov 2022 18:19:31 -0700 Subject: [PATCH 01/11] fix orderby for null int types --- ConfigGenerators/MsSqlCommands.txt | 3 ++- ConfigGenerators/MySqlCommands.txt | 3 ++- ConfigGenerators/PostgreSqlCommands.txt | 3 ++- .../SqlTests/RestApiTests/Find/FindApiTestBase.cs | 15 +++++++++++++++ .../RestApiTests/Find/MsSqlFindApiTests.cs | 6 ++++++ .../RestApiTests/Find/MySqlFindApiTests.cs | 11 +++++++++++ .../RestApiTests/Find/PostgreSqlFindApiTests.cs | 10 ++++++++++ .../SqlTests/RestApiTests/RestApiTestBase.cs | 2 ++ src/Service/Resolvers/BaseSqlQueryBuilder.cs | 9 +++++++-- .../Sql Query Structures/SqlQueryStructure.cs | 5 +++-- src/Service/Resolvers/SqlPaginationUtil.cs | 3 ++- 11 files changed, 62 insertions(+), 8 deletions(-) diff --git a/ConfigGenerators/MsSqlCommands.txt b/ConfigGenerators/MsSqlCommands.txt index b9101408b5..41a507c4c9 100644 --- a/ConfigGenerators/MsSqlCommands.txt +++ b/ConfigGenerators/MsSqlCommands.txt @@ -1,4 +1,4 @@ -init --config "dab-config.MsSql.json" --database-type mssql --connection-string "Server=tcp:127.0.0.1,1433;Persist Security Info=False;User ID=sa;Password=REPLACEME;MultipleActiveResultSets=False;Connection Timeout=5;" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" +init --config "dab-config.MsSql.json" --database-type mssql --connection-string "Server=tcp:127.0.0.1,1433;Persist Security Info=False;User ID=sa;Password=REPLACEME;MultipleActiveResultSets=False;Connection Timeout=5;" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" add Publisher --config "dab-config.MsSql.json" --source publishers --permissions "anonymous:read" add Stock --config "dab-config.MsSql.json" --source stocks --permissions "anonymous:create,read,update" add Book --config "dab-config.MsSql.json" --source books --permissions "anonymous:create,read,update,delete" --graphql "book:books" @@ -23,6 +23,7 @@ add ArtOfWar --config "dab-config.MsSql.json" --source "aow" --rest true --permi add series --config "dab-config.MsSql.json" --source "series" --permissions "anonymous:*" add GetBooks --config "dab-config.MsSql.json" --source "get_books" --source.type "stored-procedure" --permissions "anonymous:read" --rest true --graphql false add GetBook --config "dab-config.MsSql.json" --source "get_book_by_id" --source.type "stored-procedure" --permissions "anonymous:read" --rest true --graphql false +add TypeTable --config "dab-config.MsSql.json" --source "type_table" --source.type "table" --permissions "anonymous:read" --rest true --graphql true update Publisher --config "dab-config.MsSql.json" --permissions "authenticated:create,read,update,delete" --rest true --graphql true --relationship books --target.entity Book --cardinality many update Publisher --config "dab-config.MsSql.json" --permissions "policy_tester_01:create,delete" update Publisher --config "dab-config.MsSql.json" --permissions "policy_tester_01:update" --fields.include "*" diff --git a/ConfigGenerators/MySqlCommands.txt b/ConfigGenerators/MySqlCommands.txt index d8c0012975..d86d967fdd 100644 --- a/ConfigGenerators/MySqlCommands.txt +++ b/ConfigGenerators/MySqlCommands.txt @@ -1,4 +1,4 @@ -init --config "dab-config.MySql.json" --database-type mysql --connection-string "server=localhost;database=datagatewaytest;Allow User Variables=true;uid=root;pwd=REPLACEME" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" +init --config "dab-config.MySql.json" --database-type mysql --connection-string "server=localhost;database=datagatewaytest;Allow User Variables=true;uid=root;pwd=REPLACEME" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" add Publisher --config "dab-config.MySql.json" --source publishers --permissions "anonymous:read" add Stock --config "dab-config.MySql.json" --source stocks --permissions "anonymous:create,read,update" add Book --config "dab-config.MySql.json" --source books --permissions "anonymous:create,read,update,delete" --graphql "book:books" @@ -21,6 +21,7 @@ add Notebook --config "dab-config.MySql.json" --source "notebooks" --permissions add Journal --config "dab-config.MySql.json" --source "journals" --rest true --graphql true --permissions "policy_tester_noupdate:create,delete" add ArtOfWar --config "dab-config.MySql.json" --source "aow" --rest true --permissions "anonymous:*" add series --config "dab-config.MySql.json" --source "series" --permissions "anonymous:*" +add TypeTable --config "dab-config.MySql.json" --source "type_table" --source.type "table" --permissions "anonymous:read" --rest true --graphql true update Publisher --config "dab-config.MySql.json" --permissions "authenticated:create,read,update,delete" --rest true --graphql true --relationship books --target.entity Book --cardinality many update Publisher --config "dab-config.MySql.json" --permissions "policy_tester_01:create,delete" update Publisher --config "dab-config.MySql.json" --permissions "policy_tester_01:update" --fields.include "*" diff --git a/ConfigGenerators/PostgreSqlCommands.txt b/ConfigGenerators/PostgreSqlCommands.txt index 08475bf737..329bc0ca79 100644 --- a/ConfigGenerators/PostgreSqlCommands.txt +++ b/ConfigGenerators/PostgreSqlCommands.txt @@ -1,4 +1,4 @@ -init --config "dab-config.PostgreSql.json" --database-type postgresql --connection-string "Host=localhost;Database=datagatewaytest;username=REPLACEME;password=REPLACEME" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" +init --config "dab-config.PostgreSql.json" --database-type postgresql --connection-string "Host=localhost;Database=datagatewaytest;username=REPLACEME;password=REPLACEME" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" add Publisher --config "dab-config.PostgreSql.json" --source publishers --permissions "anonymous:read" add Stock --config "dab-config.PostgreSql.json" --source stocks --permissions "anonymous:create,read,update" add Book --config "dab-config.PostgreSql.json" --source books --permissions "anonymous:create,read,update,delete" --graphql "book:books" @@ -18,6 +18,7 @@ add Notebook --config "dab-config.PostgreSql.json" --source "notebooks" --permis add Journal --config "dab-config.PostgreSql.json" --source "journals" --rest true --graphql true --permissions "policy_tester_noupdate:create,delete" add ArtOfWar --config "dab-config.PostgreSql.json" --source "aow" --rest true --permissions "anonymous:*" add series --config "dab-config.PostgreSql.json" --source "series" --permissions "anonymous:*" +add TypeTable --config "dab-config.PostgreSql.json" --source "type_table" --source.type "table" --permissions "anonymous:read" --rest true --graphql true update Publisher --config "dab-config.PostgreSql.json" --permissions "authenticated:create,read,update,delete" --rest true --graphql true --relationship books --target.entity Book --cardinality many update Publisher --config "dab-config.PostgreSql.json" --permissions "policy_tester_01:create,delete" update Publisher --config "dab-config.PostgreSql.json" --permissions "policy_tester_01:update" --fields.include "*" diff --git a/src/Service.Tests/SqlTests/RestApiTests/Find/FindApiTestBase.cs b/src/Service.Tests/SqlTests/RestApiTests/Find/FindApiTestBase.cs index 52fa3eb162..7727171488 100644 --- a/src/Service.Tests/SqlTests/RestApiTests/Find/FindApiTestBase.cs +++ b/src/Service.Tests/SqlTests/RestApiTests/Find/FindApiTestBase.cs @@ -525,6 +525,21 @@ await SetupAndRunRestApiTest( ); } + /// + /// Tests the REST Api for Find operation using sorting + /// with integer type and null values. + /// + [TestMethod] + public async Task FindTestWithIntTypeNullValuesOrderByAsc() + { + await SetupAndRunRestApiTest( + primaryKeyRoute: string.Empty, + queryString: "?$orderby=int_types", + entityNameOrPath: _integrationTypeEntity, + sqlQuery: GetQuery(nameof(FindTestWithIntTypeNullValuesOrderByAsc)) + ); + } + /// /// Tests the REST Api for Find operation for all records. /// order by title in ascending order. diff --git a/src/Service.Tests/SqlTests/RestApiTests/Find/MsSqlFindApiTests.cs b/src/Service.Tests/SqlTests/RestApiTests/Find/MsSqlFindApiTests.cs index f2d4c2c2b8..dfdb816cce 100644 --- a/src/Service.Tests/SqlTests/RestApiTests/Find/MsSqlFindApiTests.cs +++ b/src/Service.Tests/SqlTests/RestApiTests/Find/MsSqlFindApiTests.cs @@ -254,6 +254,12 @@ public class MsSqlFindApiTests : FindApiTestBase $"ORDER BY book_id asc, id asc " + $"FOR JSON PATH, INCLUDE_NULL_VALUES" }, + { + "FindTestWithIntTypeNullValuesOrderByAsc", + $"SELECT * FROM type_table " + + $"ORDER BY int_types asc, id asc " + + $"FOR JSON PATH, INCLUDE_NULL_VALUES" + }, { "FindTestWithQueryStringAllFieldsOrderByAsc", $"SELECT * FROM { _integrationTableName } " + diff --git a/src/Service.Tests/SqlTests/RestApiTests/Find/MySqlFindApiTests.cs b/src/Service.Tests/SqlTests/RestApiTests/Find/MySqlFindApiTests.cs index 1d56a294ee..396c5802f7 100644 --- a/src/Service.Tests/SqlTests/RestApiTests/Find/MySqlFindApiTests.cs +++ b/src/Service.Tests/SqlTests/RestApiTests/Find/MySqlFindApiTests.cs @@ -478,6 +478,17 @@ SELECT JSON_ARRAYAGG(JSON_OBJECT('id', id, 'content', content, 'book_id', book_i LIMIT 1 ) AS subq" }, + { + "FindTestWithIntTypeNullValuesOrderByAsc", + @" + SELECT JSON_ARRAYAGG(JSON_OBJECT('id', id, 'title', title, 'publisher_id', publisher_id)) AS data + FROM ( + SELECT * + FROM " + _integrationTypeTable + @" + ORDER BY int_types asc, id asc + LIMIT 100 + ) AS subq" + }, { "FindTestWithQueryStringAllFieldsOrderByAsc", @" diff --git a/src/Service.Tests/SqlTests/RestApiTests/Find/PostgreSqlFindApiTests.cs b/src/Service.Tests/SqlTests/RestApiTests/Find/PostgreSqlFindApiTests.cs index 34f0697d47..93e5f35401 100644 --- a/src/Service.Tests/SqlTests/RestApiTests/Find/PostgreSqlFindApiTests.cs +++ b/src/Service.Tests/SqlTests/RestApiTests/Find/PostgreSqlFindApiTests.cs @@ -371,6 +371,16 @@ LIMIT 1 ) AS subq " }, + { + "FindTestWithIntTypeNullValuesOrderByAsc", + @" + SELECT json_agg(to_jsonb(subq)) AS data + FROM ( + SELECT * + FROM " + _integrationTypeTable + @" + ORDER BY int_types asc, id asc + ) AS subq" + }, { "FindTestWithQueryStringAllFieldsOrderByAsc", @" diff --git a/src/Service.Tests/SqlTests/RestApiTests/RestApiTestBase.cs b/src/Service.Tests/SqlTests/RestApiTests/RestApiTestBase.cs index b180aebe58..6f8a5d9df1 100644 --- a/src/Service.Tests/SqlTests/RestApiTests/RestApiTestBase.cs +++ b/src/Service.Tests/SqlTests/RestApiTests/RestApiTestBase.cs @@ -42,6 +42,8 @@ public abstract class RestApiTestBase : SqlTestBase protected static readonly string _integrationProcedureFindOne_ProcName = "get_book_by_id"; protected static readonly string _integrationMappingDifferentEntityPath = "plants"; protected static readonly string _Composite_NonAutoGenPK_EntityPath = "commodities"; + protected static readonly string _integrationTypeEntity = "TypeTable"; + protected static readonly string _integrationTypeTable = "type_table"; public abstract string GetQuery(string key); } diff --git a/src/Service/Resolvers/BaseSqlQueryBuilder.cs b/src/Service/Resolvers/BaseSqlQueryBuilder.cs index cf1b567829..3eb87d9195 100644 --- a/src/Service/Resolvers/BaseSqlQueryBuilder.cs +++ b/src/Service/Resolvers/BaseSqlQueryBuilder.cs @@ -72,8 +72,13 @@ private string MakePaginationInequality(List columns, int unti StringBuilder result = new(); for (int i = 0; i <= untilIndex; i++) { - string op = i == untilIndex ? GetComparisonFromDirection(columns[i].Direction) : "="; - result.Append($"{Build(columns[i], printDirection: false)} {op} {columns[i].ParamName}"); + // Combine op and param to accomodate "is NULL" which is used for + // params that have value of NULL. + string opAndParam = i == untilIndex ? + $"{GetComparisonFromDirection(columns[i].Direction)} {columns[i].ParamName}" : + columns[i].Value is not null ? + $"= {columns[i].ParamName}" : "is NULL"; + result.Append($"{Build(columns[i], printDirection: false)} {opAndParam}"); if (i < untilIndex) { diff --git a/src/Service/Resolvers/Sql Query Structures/SqlQueryStructure.cs b/src/Service/Resolvers/Sql Query Structures/SqlQueryStructure.cs index adf02230bd..9b46bc5ed3 100644 --- a/src/Service/Resolvers/Sql Query Structures/SqlQueryStructure.cs +++ b/src/Service/Resolvers/Sql Query Structures/SqlQueryStructure.cs @@ -513,8 +513,9 @@ public void AddPaginationPredicate(IEnumerable afterJsonValues foreach (PaginationColumn column in afterJsonValues) { column.TableAlias = TableAlias; - column.ParamName = "@" + MakeParamWithValue( - GetParamAsColumnSystemType(column.Value!.ToString()!, column.ColumnName)); + column.ParamName = column.Value is not null ? + "@" + MakeParamWithValue(GetParamAsColumnSystemType(column.Value!.ToString()!, column.ColumnName)) : + "@" + MakeParamWithValue(null); } } catch (ArgumentException ex) diff --git a/src/Service/Resolvers/SqlPaginationUtil.cs b/src/Service/Resolvers/SqlPaginationUtil.cs index 2a6745c034..d597d3883b 100644 --- a/src/Service/Resolvers/SqlPaginationUtil.cs +++ b/src/Service/Resolvers/SqlPaginationUtil.cs @@ -374,10 +374,11 @@ private static string GetExposedColumnName(string entityName, string backingColu /// Resolves a JsonElement representing a variable to the appropriate type /// /// - public static object ResolveJsonElementToScalarVariable(JsonElement element) => element.ValueKind switch + public static object? ResolveJsonElementToScalarVariable(JsonElement element) => element.ValueKind switch { JsonValueKind.String => element.GetString()!, JsonValueKind.Number => element.GetInt64(), + JsonValueKind.Null => null, JsonValueKind.True => true, JsonValueKind.False => false, _ => throw new ArgumentException("Unexpected JsonElement value"), From 4534c0e7313a2f18e790071eb5fa32193fa91fb1 Mon Sep 17 00:00:00 2001 From: aaron burtle Date: Tue, 6 Dec 2022 18:05:10 -0800 Subject: [PATCH 02/11] add GQL logging of entities on startup --- src/Config/RuntimeConfig.cs | 6 +++++- src/Service/Configurations/RuntimeConfigProvider.cs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Config/RuntimeConfig.cs b/src/Config/RuntimeConfig.cs index a51aa16332..d4d481c0f2 100644 --- a/src/Config/RuntimeConfig.cs +++ b/src/Config/RuntimeConfig.cs @@ -137,7 +137,7 @@ public void DetermineGraphQLEntityNames() /// This is used for looking up top-level entity name with GraphQL type, GraphQL type is not matching any of the top level entity name. /// Use singular field to find the top level entity name, then do the look up from the entities dictionary /// - public void MapGraphQLSingularTypeToEntityName() + public void MapGraphQLSingularTypeToEntityName(ILogger? logger) { foreach (KeyValuePair item in Entities) { @@ -160,6 +160,10 @@ public void MapGraphQLSingularTypeToEntityName() if (graphQLType is not null) { GraphQLSingularTypeToEntityNameMap.TryAdd(graphQLType, entityName); + if (logger is not null) + { + logger.LogInformation($"GraphQL Entity: {GraphQLGlobalSettings.Path}/{entityName}"); + } } } } diff --git a/src/Service/Configurations/RuntimeConfigProvider.cs b/src/Service/Configurations/RuntimeConfigProvider.cs index 0a71a19b5f..3743114771 100644 --- a/src/Service/Configurations/RuntimeConfigProvider.cs +++ b/src/Service/Configurations/RuntimeConfigProvider.cs @@ -131,7 +131,7 @@ public static bool LoadRuntimeConfigValue( out runtimeConfig, ConfigProviderLogger)) { - runtimeConfig!.MapGraphQLSingularTypeToEntityName(); + runtimeConfig!.MapGraphQLSingularTypeToEntityName(ConfigProviderLogger); if (!string.IsNullOrWhiteSpace(configPath?.CONNSTRING)) { runtimeConfig!.ConnectionString = configPath.CONNSTRING; @@ -236,7 +236,7 @@ public void Initialize( ConfigProviderLogger!)) { RuntimeConfiguration = runtimeConfig; - RuntimeConfiguration!.MapGraphQLSingularTypeToEntityName(); + RuntimeConfiguration!.MapGraphQLSingularTypeToEntityName(ConfigProviderLogger); RuntimeConfiguration!.ConnectionString = connectionString; if (RuntimeConfiguration!.DatabaseType == DatabaseType.cosmos) From 4188b22dec15fc69639d92a0cc9185b1cc7f828d Mon Sep 17 00:00:00 2001 From: aaronburtle <93220300+aaronburtle@users.noreply.github.com> Date: Tue, 6 Dec 2022 21:37:59 -0800 Subject: [PATCH 03/11] Update MsSqlCommands.txt --- ConfigGenerators/MsSqlCommands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConfigGenerators/MsSqlCommands.txt b/ConfigGenerators/MsSqlCommands.txt index a8cffb1464..a7b87c5afa 100644 --- a/ConfigGenerators/MsSqlCommands.txt +++ b/ConfigGenerators/MsSqlCommands.txt @@ -1,4 +1,4 @@ -init --config "dab-config.MsSql.json" --database-type mssql --connection-string "Server=tcp:127.0.0.1,1433;Persist Security Info=False;User ID=sa;Password=REPLACEME;MultipleActiveResultSets=False;Connection Timeout=5;" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" +init --config "dab-config.MsSql.json" --database-type mssql --connection-string "Server=tcp:127.0.0.1,1433;Persist Security Info=False;User ID=sa;Password=REPLACEME;MultipleActiveResultSets=False;Connection Timeout=5;" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" add Publisher --config "dab-config.MsSql.json" --source publishers --permissions "anonymous:read" add Stock --config "dab-config.MsSql.json" --source stocks --permissions "anonymous:create,read,update" add Book --config "dab-config.MsSql.json" --source books --permissions "anonymous:create,read,update,delete" --graphql "book:books" From b32b78f0a2276f2bb514deddd486ff983a0bc990 Mon Sep 17 00:00:00 2001 From: aaronburtle <93220300+aaronburtle@users.noreply.github.com> Date: Tue, 6 Dec 2022 21:38:13 -0800 Subject: [PATCH 04/11] Update MySqlCommands.txt --- ConfigGenerators/MySqlCommands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConfigGenerators/MySqlCommands.txt b/ConfigGenerators/MySqlCommands.txt index ff62781d90..52aa23a7a0 100644 --- a/ConfigGenerators/MySqlCommands.txt +++ b/ConfigGenerators/MySqlCommands.txt @@ -1,4 +1,4 @@ -init --config "dab-config.MySql.json" --database-type mysql --connection-string "server=localhost;database=datagatewaytest;Allow User Variables=true;uid=root;pwd=REPLACEME" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" +init --config "dab-config.MySql.json" --database-type mysql --connection-string "server=localhost;database=datagatewaytest;Allow User Variables=true;uid=root;pwd=REPLACEME" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" add Publisher --config "dab-config.MySql.json" --source publishers --permissions "anonymous:read" add Stock --config "dab-config.MySql.json" --source stocks --permissions "anonymous:create,read,update" add Book --config "dab-config.MySql.json" --source books --permissions "anonymous:create,read,update,delete" --graphql "book:books" From 890117b1026c0c383917079742fccf9ee74c70b2 Mon Sep 17 00:00:00 2001 From: aaronburtle <93220300+aaronburtle@users.noreply.github.com> Date: Tue, 6 Dec 2022 21:38:26 -0800 Subject: [PATCH 05/11] Update PostgreSqlCommands.txt --- ConfigGenerators/PostgreSqlCommands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConfigGenerators/PostgreSqlCommands.txt b/ConfigGenerators/PostgreSqlCommands.txt index d65f5e61f2..a7cafb7a82 100644 --- a/ConfigGenerators/PostgreSqlCommands.txt +++ b/ConfigGenerators/PostgreSqlCommands.txt @@ -1,4 +1,4 @@ -init --config "dab-config.PostgreSql.json" --database-type postgresql --connection-string "Host=localhost;Database=datagatewaytest;username=REPLACEME;password=REPLACEME" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" +init --config "dab-config.PostgreSql.json" --database-type postgresql --connection-string "Host=localhost;Database=datagatewaytest;username=REPLACEME;password=REPLACEME" --host-mode Development --authenticate-devmode-requests false --cors-origin "http://localhost:5000" add Publisher --config "dab-config.PostgreSql.json" --source publishers --permissions "anonymous:read" add Stock --config "dab-config.PostgreSql.json" --source stocks --permissions "anonymous:create,read,update" add Book --config "dab-config.PostgreSql.json" --source books --permissions "anonymous:create,read,update,delete" --graphql "book:books" From 4c9012bbc80f637aefc18e2a9e68aa8d41ecc061 Mon Sep 17 00:00:00 2001 From: aaron burtle Date: Wed, 7 Dec 2022 08:37:35 -0800 Subject: [PATCH 06/11] changed logging to match comments --- src/Config/RuntimeConfig.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Config/RuntimeConfig.cs b/src/Config/RuntimeConfig.cs index cee03376c1..c265b9b3fb 100644 --- a/src/Config/RuntimeConfig.cs +++ b/src/Config/RuntimeConfig.cs @@ -138,8 +138,20 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) { GraphQLEntitySettings? graphQL = entity.GraphQL as GraphQLEntitySettings; - if (graphQL is null || graphQL.Type is null - || (graphQL.Type is not SingularPlural && graphQL.Type is not string)) + if (graphQL is null) + { + continue; + } + else if (graphQL.Type is null) + { + if (logger is not null) + { + logger.LogInformation($"GraphQL type for {entityName} is {entityName}"); + } + + continue; + } + else if (graphQL.Type is not SingularPlural && graphQL.Type is not string) { continue; } @@ -151,7 +163,7 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) GraphQLSingularTypeToEntityNameMap.TryAdd(graphQLType, entityName); if (logger is not null) { - logger.LogInformation($"GraphQL Entity: {GraphQLGlobalSettings.Path}/{entityName}"); + logger.LogInformation($"GraphQL type for {entityName} is {graphQLType}"); } } } From a378c09358fcf52960b65768b50c8b7eb8436719 Mon Sep 17 00:00:00 2001 From: aaron burtle Date: Wed, 7 Dec 2022 16:16:17 -0800 Subject: [PATCH 07/11] src/Config/RuntimeConfig.cs --- src/Config/RuntimeConfig.cs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Config/RuntimeConfig.cs b/src/Config/RuntimeConfig.cs index c265b9b3fb..97759ac8ff 100644 --- a/src/Config/RuntimeConfig.cs +++ b/src/Config/RuntimeConfig.cs @@ -138,20 +138,8 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) { GraphQLEntitySettings? graphQL = entity.GraphQL as GraphQLEntitySettings; - if (graphQL is null) - { - continue; - } - else if (graphQL.Type is null) - { - if (logger is not null) - { - logger.LogInformation($"GraphQL type for {entityName} is {entityName}"); - } - - continue; - } - else if (graphQL.Type is not SingularPlural && graphQL.Type is not string) + if (graphQL is null || graphQL.Type is null + || (graphQL.Type is not SingularPlural && graphQL.Type is not string)) { continue; } @@ -163,10 +151,24 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) GraphQLSingularTypeToEntityNameMap.TryAdd(graphQLType, entityName); if (logger is not null) { + // We have the GraphqlType so we log that logger.LogInformation($"GraphQL type for {entityName} is {graphQLType}"); } } } + + // Log every entity that is not disabled for GQL + if (entity.GraphQL is not null && entity.GraphQL is false) + { + continue; + } + else + { + if (logger is not null) + { + logger.LogInformation($"GraphQL type for {entityName} is {entityName}"); + } + } } } From e237bb98dcf7a1653bc76d126e67ea4eeeb05b15 Mon Sep 17 00:00:00 2001 From: aaron burtle Date: Wed, 7 Dec 2022 16:23:28 -0800 Subject: [PATCH 08/11] cover case of no gql type but also not bool --- src/Config/RuntimeConfig.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Config/RuntimeConfig.cs b/src/Config/RuntimeConfig.cs index 97759ac8ff..278aac92a1 100644 --- a/src/Config/RuntimeConfig.cs +++ b/src/Config/RuntimeConfig.cs @@ -141,6 +141,12 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) if (graphQL is null || graphQL.Type is null || (graphQL.Type is not SingularPlural && graphQL.Type is not string)) { + if (logger is not null) + { + // Use entity name since GraphQL type unavailable + logger.LogInformation($"GraphQL type for {entityName} is {entityName}"); + } + continue; } @@ -151,7 +157,7 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) GraphQLSingularTypeToEntityNameMap.TryAdd(graphQLType, entityName); if (logger is not null) { - // We have the GraphqlType so we log that + // We have the GraphQL type so we log that logger.LogInformation($"GraphQL type for {entityName} is {graphQLType}"); } } @@ -166,6 +172,7 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) { if (logger is not null) { + // Use entity name since GraphQL type uavailable logger.LogInformation($"GraphQL type for {entityName} is {entityName}"); } } From 943f733b9f685d65f20a146262b24047201024c3 Mon Sep 17 00:00:00 2001 From: aaron burtle Date: Wed, 7 Dec 2022 20:24:43 -0800 Subject: [PATCH 09/11] syntactic sugar --- src/Config/RuntimeConfig.cs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Config/RuntimeConfig.cs b/src/Config/RuntimeConfig.cs index 278aac92a1..0f1f8a79ec 100644 --- a/src/Config/RuntimeConfig.cs +++ b/src/Config/RuntimeConfig.cs @@ -141,12 +141,8 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) if (graphQL is null || graphQL.Type is null || (graphQL.Type is not SingularPlural && graphQL.Type is not string)) { - if (logger is not null) - { - // Use entity name since GraphQL type unavailable - logger.LogInformation($"GraphQL type for {entityName} is {entityName}"); - } - + // Use entity name since GraphQL type unavailable + logger?.LogInformation($"GraphQL type for {entityName} is {entityName}"); continue; } @@ -155,11 +151,8 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) if (graphQLType is not null) { GraphQLSingularTypeToEntityNameMap.TryAdd(graphQLType, entityName); - if (logger is not null) - { - // We have the GraphQL type so we log that - logger.LogInformation($"GraphQL type for {entityName} is {graphQLType}"); - } + // We have the GraphQL type so we log that + logger?.LogInformation($"GraphQL type for {entityName} is {graphQLType}"); } } @@ -170,11 +163,9 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) } else { - if (logger is not null) - { - // Use entity name since GraphQL type uavailable - logger.LogInformation($"GraphQL type for {entityName} is {entityName}"); - } + // Use entity name since GraphQL type uavailable + logger?.LogInformation($"GraphQL type for {entityName} is {entityName}"); + } } } From a60d4d6adf041cc24e8487dbb50d2cb852ee1357 Mon Sep 17 00:00:00 2001 From: aaron burtle Date: Wed, 7 Dec 2022 22:35:45 -0800 Subject: [PATCH 10/11] better style --- src/Config/RuntimeConfig.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Config/RuntimeConfig.cs b/src/Config/RuntimeConfig.cs index 0f1f8a79ec..71767e7ce4 100644 --- a/src/Config/RuntimeConfig.cs +++ b/src/Config/RuntimeConfig.cs @@ -157,15 +157,10 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) } // Log every entity that is not disabled for GQL - if (entity.GraphQL is not null && entity.GraphQL is false) - { - continue; - } - else + if (entity.GraphQL is null || entity.GraphQL is true) { // Use entity name since GraphQL type uavailable logger?.LogInformation($"GraphQL type for {entityName} is {entityName}"); - } } } From 42dabafc370136cf14029af4e9700ded99ccb505 Mon Sep 17 00:00:00 2001 From: aaronburtle <93220300+aaronburtle@users.noreply.github.com> Date: Wed, 7 Dec 2022 23:07:41 -0800 Subject: [PATCH 11/11] Update src/Config/RuntimeConfig.cs Co-authored-by: Aniruddh Munde --- src/Config/RuntimeConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/RuntimeConfig.cs b/src/Config/RuntimeConfig.cs index 71767e7ce4..2afc1dfa9b 100644 --- a/src/Config/RuntimeConfig.cs +++ b/src/Config/RuntimeConfig.cs @@ -159,7 +159,7 @@ public void MapGraphQLSingularTypeToEntityName(ILogger? logger) // Log every entity that is not disabled for GQL if (entity.GraphQL is null || entity.GraphQL is true) { - // Use entity name since GraphQL type uavailable + // Use entity name since GraphQL type unavailable logger?.LogInformation($"GraphQL type for {entityName} is {entityName}"); } }