Skip to content

Commit 217173e

Browse files
committed
Misc tidy-up
1 parent 84768c6 commit 217173e

File tree

134 files changed

+701
-542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+701
-542
lines changed

src/GraphQL.Conventions/Adapters/Engine/DocumentExecuter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77

8+
// ReSharper disable once CheckNamespace
89
namespace GraphQL.Conventions
910
{
1011
public class DocumentExecuter : IDocumentExecuter
@@ -51,4 +52,4 @@ public Task<ExecutionResult> ExecuteAsync(Action<ExecutionOptions> configure)
5152
throw new NotImplementedException();
5253
}
5354
}
54-
}
55+
}

src/GraphQL.Conventions/Adapters/Engine/GraphQLEngine.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using GraphQL.Conventions.Adapters.Engine.ErrorTransformations;
99
using GraphQL.Conventions.Adapters.Engine.Listeners.DataLoader;
1010
using GraphQL.Conventions.Builders;
11-
using GraphQL.Conventions.Execution;
1211
using GraphQL.Conventions.Extensions;
1312
using GraphQL.Conventions.Types.Descriptors;
1413
using GraphQL.Conventions.Types.Resolution;
@@ -20,6 +19,7 @@
2019
using GraphQL.Validation;
2120
using GraphQL.Validation.Complexity;
2221

22+
// ReSharper disable once CheckNamespace
2323
namespace GraphQL.Conventions
2424
{
2525
public class GraphQLEngine
@@ -289,8 +289,8 @@ internal async Task<ExecutionResult> ExecuteAsync(
289289
Inputs = inputs,
290290
UserContext = new Dictionary<string, object>()
291291
{
292-
{ typeof(IUserContext).FullName, userContext},
293-
{ typeof(IDependencyInjector).FullName, dependencyInjector ?? new WrappedDependencyInjector(_constructor.TypeResolutionDelegate)},
292+
{ typeof(IUserContext).FullName ?? nameof(IUserContext), userContext},
293+
{ typeof(IDependencyInjector).FullName ?? nameof(IDependencyInjector), dependencyInjector ?? new WrappedDependencyInjector(_constructor.TypeResolutionDelegate)},
294294
},
295295
ValidationRules = validationRules.Any() ? validationRules : null,
296296
ComplexityConfiguration = complexityConfiguration,
@@ -358,4 +358,4 @@ private object CreateInstance(System.Type type)
358358
return Activator.CreateInstance(type);
359359
}
360360
}
361-
}
361+
}

src/GraphQL.Conventions/Adapters/Engine/GraphQLExecutor.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using GraphQL.Validation;
66
using GraphQL.Validation.Complexity;
77

8+
// ReSharper disable once CheckNamespace
89
namespace GraphQL.Conventions
910
{
1011
public class GraphQLExecutor : IGraphQLExecutor<ExecutionResult>
@@ -23,17 +24,17 @@ public class GraphQLExecutor : IGraphQLExecutor<ExecutionResult>
2324

2425
private Inputs _inputs;
2526

26-
private CancellationToken _cancellationToken = default;
27+
private CancellationToken _cancellationToken;
2728

2829
private IDependencyInjector _dependencyInjector;
2930

3031
private bool _enableValidation = true;
3132

32-
private bool _enableProfiling = false;
33+
private bool _enableProfiling;
3334

34-
private IEnumerable<IValidationRule> _validationRules = null;
35+
private IEnumerable<IValidationRule> _validationRules;
3536

36-
private ComplexityConfiguration _complexityConfiguration = null;
37+
private ComplexityConfiguration _complexityConfiguration;
3738

3839
private IEnumerable<IDocumentExecutionListener> _documentExecutionListeners;
3940

@@ -150,4 +151,4 @@ public Task<ExecutionResult> ExecuteAsync()
150151

151152
public Task<IValidationResult> ValidateAsync() => _engine.ValidateAsync(_queryString);
152153
}
153-
}
154+
}

src/GraphQL.Conventions/Adapters/Engine/IGraphQLExecutor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using GraphQL.Validation;
66
using GraphQL.Validation.Complexity;
77

8+
// ReSharper disable once CheckNamespace
89
namespace GraphQL.Conventions
910
{
1011
public interface IGraphQLExecutor<TResult>
@@ -40,9 +41,9 @@ public interface IGraphQLExecutor<TResult>
4041
IGraphQLExecutor<TResult> EnableProfiling(bool enableProfiling = true);
4142

4243
IGraphQLExecutor<TResult> DisableProfiling();
43-
44+
4445
Task<TResult> ExecuteAsync();
45-
46+
4647
Task<IValidationResult> ValidateAsync();
4748
}
4849
}

src/GraphQL.Conventions/Adapters/Engine/Listeners/DataLoader/DataLoaderListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class DataLoaderListener : DocumentExecutionListenerBase
88
{
99
public override async Task AfterValidationAsync(IExecutionContext context, IValidationResult validationResult)
1010
{
11-
var key = typeof(IUserContext).FullName;
11+
var key = typeof(IUserContext).FullName ?? nameof(IUserContext);
1212
if (context.UserContext.ContainsKey(key) && context.UserContext[key] is IDataLoaderContextProvider provider)
1313
await provider.FetchData(context.CancellationToken).ConfigureAwait(false);
1414
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using System.Threading;
22
using System.Threading.Tasks;
33

4+
// ReSharper disable once CheckNamespace
45
namespace GraphQL.Conventions
56
{
67
public interface IDataLoaderContextProvider : IUserContext
78
{
89
Task FetchData(CancellationToken token);
910
}
10-
}
11+
}

src/GraphQL.Conventions/Adapters/Engine/Utilities/IRequestDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22

3+
// ReSharper disable once CheckNamespace
34
namespace GraphQL.Conventions
45
{
56
public interface IRequestDeserializer

src/GraphQL.Conventions/Adapters/Engine/Utilities/QueryInput.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22

3+
// ReSharper disable once CheckNamespace
34
namespace GraphQL.Conventions
45
{
56
public class QueryInput

src/GraphQL.Conventions/Adapters/Engine/Utilities/RequestDeserializer.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Newtonsoft.Json;
55
using Newtonsoft.Json.Linq;
66

7+
// ReSharper disable once CheckNamespace
78
namespace GraphQL.Conventions
89
{
910
public class RequestDeserializer : IRequestDeserializer
@@ -21,27 +22,24 @@ public QueryInput GetQueryFromRequestBody(string requestBody)
2122
throw new ArgumentException($"Unable to deserialize JSON '{requestBody}'.");
2223
}
2324

24-
object data;
25-
object queryString;
26-
27-
if (!request.TryGetValue("query", out queryString) && request.TryGetValue("data", out data))
25+
if (!request.TryGetValue("query", out var queryString) && request.TryGetValue("data", out var data))
2826
{
2927
request = data as Dictionary<string, object>;
3028
}
3129

32-
if (request.TryGetValue("query", out queryString))
30+
if (request?.TryGetValue("query", out queryString) ?? false)
3331
{
3432
query.QueryString = queryString as string ?? string.Empty;
3533
}
3634

37-
object operationName;
38-
if (request.TryGetValue("operationName", out operationName))
35+
object operationName = null;
36+
if (request?.TryGetValue("operationName", out operationName) ?? false)
3937
{
4038
query.OperationName = operationName as string;
4139
}
4240

43-
object variables;
44-
if (request.TryGetValue("variables", out variables))
41+
object variables = null;
42+
if (request?.TryGetValue("variables", out variables) ?? false)
4543
{
4644
var variablesString = variables as string;
4745
if (!string.IsNullOrWhiteSpace(variablesString))

src/GraphQL.Conventions/Adapters/GraphTypeAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ISchema DeriveSchema(GraphSchemaInfo schemaInfo)
3333
var possibleTypes = interfaces
3434
.Where(t => !t.IsIgnored)
3535
.SelectMany(t => t.PossibleTypes)
36-
.Select(typeInfo => (typeInfo.IsIgnored || !typeInfo.IsNullable || typeInfo.Interfaces.Any(x => x.IsIgnored == true))
36+
.Select(typeInfo => (typeInfo.IsIgnored || !typeInfo.IsNullable || typeInfo.Interfaces.Any(x => x.IsIgnored))
3737
? null
3838
: DeriveType(typeInfo)
3939
)

0 commit comments

Comments
 (0)