Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate HotChocolate.Data to new selections #5178

Merged
merged 13 commits into from
Jun 27, 2022
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-azuretools.vscode-azurefunctions",
"ms-dotnettools.csharp"
]
}
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"azureFunctions.deploySubpath": "templates/v12/function/bin/Release/net6.0/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectSubpath": "templates/v12/function",
"azureFunctions.preDeployTask": "publish (functions)"
}
86 changes: 76 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"args": [
"build",
"src/All.sln",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
Expand All @@ -28,9 +26,7 @@
"args": [
"build",
"src/HotChocolate/Core",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
Expand All @@ -46,9 +42,7 @@
"args": [
"build",
"src/HotChocolate/Core/test/Types.Analyzers.Tests",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
Expand All @@ -64,9 +58,7 @@
"args": [
"build",
"src/StrawberryShake/CodeGeneration",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
Expand All @@ -82,16 +74,90 @@
"args": [
"build",
"src/StrawberryShake/SourceGenerator",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "clean (functions)",
"command": "dotnet",
"args": [
"clean",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/templates/v12/function"
}
},
{
"label": "build (functions)",
"command": "dotnet",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean (functions)",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/templates/v12/function"
}
},
{
"label": "clean release (functions)",
"command": "dotnet",
"args": [
"clean",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/templates/v12/function"
}
},
{
"label": "publish (functions)",
"command": "dotnet",
"args": [
"publish",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean release (functions)",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/templates/v12/function"
}
},
{
"type": "func",
"dependsOn": "build (functions)",
"options": {
"cwd": "${workspaceFolder}/templates/v12/function/bin/Debug/net6.0"
},
"command": "host start",
"isBackground": true,
"problemMatcher": "$func-dotnet-watch"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static async ValueTask<AutoUpdateRequestExecutorProxy> CreateAsync(
throw new ArgumentNullException(nameof(requestExecutorProxy));
}

IRequestExecutor executor = await requestExecutorProxy
var executor = await requestExecutorProxy
.GetRequestExecutorAsync(cancellationToken)
.ConfigureAwait(false);

Expand Down Expand Up @@ -159,7 +159,7 @@ private async ValueTask UpdateExecutorAsync()

try
{
IRequestExecutor executor = await _executorProxy
var executor = await _executorProxy
.GetRequestExecutorAsync(default)
.ConfigureAwait(false);
_executor = executor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public async IAsyncEnumerator<IQueryResult> GetAsyncEnumerator(
{
for (var i = 0; i < _requestBatch.Count; i++)
{
IQueryRequest queryRequest = _requestBatch[i];
var queryRequest = _requestBatch[i];
var request = (IReadOnlyQueryRequest)queryRequest;
IQueryResult result = await ExecuteNextAsync(
var result = await ExecuteNextAsync(
request, cancellationToken).ConfigureAwait(false);
yield return result;

Expand All @@ -72,11 +72,11 @@ private async Task<IQueryResult> ExecuteNextAsync(
{
try
{
DocumentNode document = request.Query is QueryDocument d
var document = request.Query is QueryDocument d
? d.Document
: Utf8GraphQLParser.Parse(request.Query!.AsSpan());

OperationDefinitionNode operation =
var operation =
document.GetOperation(request.OperationName);

if (document != _previous)
Expand All @@ -93,7 +93,7 @@ private async Task<IQueryResult> ExecuteNextAsync(
_previous = document;
document = RewriteDocument(operation);
operation = (OperationDefinitionNode)document.Definitions[0];
IReadOnlyDictionary<string, object?>? variableValues =
var variableValues =
MergeVariables(request.VariableValues, operation);

request = QueryRequestBuilder.From(request)
Expand Down Expand Up @@ -147,10 +147,10 @@ private DocumentNode RewriteDocument(
return variables;
}

ILookup<string, ExportedVariable> exported = _exportedVariables.ToLookup(t => t.Name);
var exported = _exportedVariables.ToLookup(t => t.Name);
var merged = new Dictionary<string, object?>();

foreach (VariableDefinitionNode variableDefinition in operation.VariableDefinitions)
foreach (var variableDefinition in operation.VariableDefinitions)
{
var variableName = variableDefinition.Variable.Name.Value;

Expand All @@ -177,7 +177,7 @@ private DocumentNode RewriteDocument(
}
}

foreach (ExportedVariable variable in exported[variableName])
foreach (var variable in exported[variableName])
{
SerializeListValue(variable, variableDefinition.Type, list);
}
Expand Down Expand Up @@ -207,7 +207,7 @@ private object Serialize(ExportedVariable exported, ITypeNode type)
{
if (_requestExecutor.Schema.TryGetType<INamedInputType>(
type.NamedType().Name.Value,
out INamedInputType? inputType)
out var inputType)
&& _typeConverter.TryConvert(
inputType!.RuntimeType,
exported.Value,
Expand All @@ -226,7 +226,7 @@ private void SerializeListValue(
{
if (_requestExecutor.Schema.TryGetType<INamedInputType>(
type.NamedType().Name.Value,
out INamedInputType? inputType))
out var inputType))
{
SerializeListValue(exported, inputType, list);
}
Expand All @@ -241,7 +241,7 @@ private void SerializeListValue(
INamedInputType inputType,
ICollection<object?> list)
{
Type runtimeType = inputType.RuntimeType;
var runtimeType = inputType.RuntimeType;

if (exported.Type.IsListType()
&& exported.Value is IEnumerable l)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected override void ResolveChildren(
IList<SyntaxNodeInfo> children)
{
if (_fragments is not null &&
_fragments.TryGetValue(node.Name.Value, out FragmentDefinitionNode? d))
_fragments.TryGetValue(node.Name.Value, out var d))
{
ResolveChildren(
d.Name.Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public VisitorAction Enter(
_action.Clear();
_touchedFragments.Clear();

ObjectType type = _schema.GetOperationType(node.Operation)!;
var type = _schema.GetOperationType(node.Operation)!;
_type.Push(type);

for (var i = 0; i < node.VariableDefinitions.Count; i++)
Expand Down Expand Up @@ -82,7 +82,7 @@ public VisitorAction Enter(
{
if (_type.Peek().NamedType() is IComplexOutputType complexType
&& complexType.Fields.TryGetField(
node.Name.Value, out IOutputField? field))
node.Name.Value, out var field))
{
_field.Push(field);
_type.Push(field.Type);
Expand Down Expand Up @@ -116,7 +116,7 @@ public VisitorAction Enter(
{
if (_field.Peek().Arguments.TryGetField(
node.Name.Value,
out IInputField? field))
out var field))
{
_type.Push(field.Type);
_action.Push(VisitorAction.Continue);
Expand Down Expand Up @@ -181,11 +181,11 @@ public VisitorAction Enter(
{
if (!_declared.Contains(node.Name.Value))
{
IType type = _type.Peek();
var type = _type.Peek();

if (_variables.TryGetValue(
node.Name.Value,
out VariableDefinitionNode? d))
out var d))
{
if (type.IsNonNullType()
&& d.Type is INullableTypeNode nullable)
Expand All @@ -198,8 +198,8 @@ public VisitorAction Enter(
{
if (type.NamedType() is IComplexOutputType complexType)
{
Type clrType = complexType.ToRuntimeType();
InputObjectType inputType =
var clrType = complexType.ToRuntimeType();
var inputType =
_schema.Types.OfType<InputObjectType>()
.First(t => t.RuntimeType == clrType);

Expand Down Expand Up @@ -252,7 +252,7 @@ public VisitorAction Enter(
IReadOnlyList<ISyntaxNode> ancestors)
{
if (node.TypeCondition is not null &&
_schema.TryGetType<INamedType>(node.TypeCondition.Name.Value, out INamedType? type))
_schema.TryGetType<INamedType>(node.TypeCondition.Name.Value, out var type))
{
_type.Push(type);
_action.Push(VisitorAction.Continue);
Expand Down Expand Up @@ -282,7 +282,7 @@ public VisitorAction Enter(
IReadOnlyList<object> path,
IReadOnlyList<ISyntaxNode> ancestors)
{
if (_schema.TryGetType<INamedType>(node.TypeCondition.Name.Value, out INamedType? type))
if (_schema.TryGetType<INamedType>(node.TypeCondition.Name.Value, out var type))
{
_touchedFragments.Add(node.Name.Value);
_type.Push(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public async ValueTask<RequestExecutorSetup> GetAsync(

if (_configs.TryGetValue(
schemaName,
out List<IConfigureRequestExecutorSetup>? configurations))
out var configurations))
{
foreach (IConfigureRequestExecutorSetup configuration in configurations)
foreach (var configuration in configurations)
{
configuration.Configure(options);
}
Expand All @@ -61,19 +61,19 @@ private async ValueTask InitializeAsync(CancellationToken cancellationToken)
{
_configs.Clear();

foreach (IRequestExecutorOptionsProvider provider in _optionsProviders)
foreach (var provider in _optionsProviders)
{
_disposables.Add(provider.OnChange(OnChange));

IEnumerable<IConfigureRequestExecutorSetup> allConfigurations =
var allConfigurations =
await provider.GetOptionsAsync(cancellationToken)
.ConfigureAwait(false);

foreach (IConfigureRequestExecutorSetup configuration in allConfigurations)
foreach (var configuration in allConfigurations)
{
if (!_configs.TryGetValue(
configuration.SchemaName,
out List<IConfigureRequestExecutorSetup>? configurations))
out var configurations))
{
configurations = new List<IConfigureRequestExecutorSetup>();
_configs.Add(configuration.SchemaName, configurations);
Expand All @@ -99,7 +99,7 @@ private void OnChange(IConfigureRequestExecutorSetup changes)

lock (_listeners)
{
foreach (Action<NameString> listener in _listeners)
foreach (var listener in _listeners)
{
listener.Invoke(changes.SchemaName);
}
Expand All @@ -112,7 +112,7 @@ public void Dispose()
{
_semaphore.Dispose();

foreach (IDisposable disposable in _disposables)
foreach (var disposable in _disposables)
{
disposable.Dispose();
}
Expand Down
Loading