Skip to content

Commit

Permalink
Execution Engine Improvements for Projections, Stitching and Federation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Jul 11, 2022
2 parents 93aad94 + 99d74ad commit 80350d8
Show file tree
Hide file tree
Showing 2,415 changed files with 87,009 additions and 120,560 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dotnet_style_null_propagation = true:suggestion
# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false
csharp_style_var_elsewhere = true:suggestion

# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:none
Expand Down
2 changes: 1 addition & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 120
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
daysUntilClose: 30
# Issues with these labels will never be considered stale
exemptLabels:
- '📌 pinned'
Expand Down
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 @@ -32,7 +32,7 @@ public AnyType()
/// <param name="bind">
/// Defines if this scalar shall bind implicitly to <see cref="SelectionSetNode"/>.
/// </param>
public AnyType(NameString name, BindingBehavior bind = BindingBehavior.Explicit)
public AnyType(string name, BindingBehavior bind = BindingBehavior.Explicit)
: base(name, bind)
{
Description = FederationResources.Any_Description;
Expand Down Expand Up @@ -108,7 +108,7 @@ public override bool TryDeserialize(object? resultValue, out object? runtimeValu

if (resultValue is ObjectValueNode ovn)
{
ObjectFieldNode? typeField = ovn.Fields.SingleOrDefault(
var typeField = ovn.Fields.SingleOrDefault(
field => field.Name.Value.EqualsOrdinal(TypeNameField));

if (typeField?.Value is StringValueNode svn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void OnCompleteDefinition(ObjectTypeDefinition definition)
throw new ArgumentNullException(nameof(method));
}

MemberInfo member = method.TryExtractMember(true);
var member = method.TryExtractMember(true);

if (member is MethodInfo m)
{
Expand Down Expand Up @@ -131,7 +131,7 @@ public IObjectTypeDescriptor ResolveReferenceWith(MethodInfo method)

var argumentBuilder = new ReferenceResolverArgumentExpressionBuilder();

FieldResolverDelegates resolver =
var resolver =
Context.ResolverCompiler.CompileResolve(
method,
sourceType: typeof(object),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using HotChocolate.ApolloFederation.Constants;
using HotChocolate.Language;
using HotChocolate.Types.Introspection;
using HotChocolate.Utilities;
using HotChocolate.Utilities.Introspection;

namespace HotChocolate.ApolloFederation;
Expand All @@ -13,7 +14,7 @@ namespace HotChocolate.ApolloFederation;
/// </summary>
public static partial class FederationSchemaPrinter
{
private readonly static HashSet<string> _builtInDirectives = new()
private static readonly HashSet<string> _builtInDirectives = new()
{
WellKnownTypeNames.External,
WellKnownTypeNames.Requires,
Expand Down Expand Up @@ -53,25 +54,25 @@ private static DocumentNode SerializeSchema(ISchema schema)
var context = new Context();
var definitionNodes = new List<IDefinitionNode>();

foreach (DirectiveType directive in schema.DirectiveTypes)
foreach (var directive in schema.DirectiveTypes)
{
if (directive.IsPublic)
{
context.DirectiveNames.Add(directive.Name);
}
}

foreach (INamedType namedType in GetRelevantTypes(schema))
foreach (var namedType in GetRelevantTypes(schema))
{
if (TrySerializeType(namedType, context, out IDefinitionNode? definitionNode))
if (TrySerializeType(namedType, context, out var definitionNode))
{
definitionNodes.Add(definitionNode);
}
}

foreach (DirectiveType directive in schema.DirectiveTypes)
foreach (var directive in schema.DirectiveTypes)
{
if (!_builtInDirectives.Contains(directive.Name.Value) && directive.IsPublic)
if (!_builtInDirectives.Contains(directive.Name) && directive.IsPublic)
{
definitionNodes.Add(SerializeDirectiveTypeDefinition(directive, context));
}
Expand All @@ -83,7 +84,7 @@ private static DocumentNode SerializeSchema(ISchema schema)
private static IEnumerable<INamedType> GetRelevantTypes(ISchema schema)
=> schema.Types
.Where(IncludeType)
.OrderBy(t => t.Name.Value, StringComparer.Ordinal);
.OrderBy(t => t.Name, StringComparer.Ordinal);

private static bool TrySerializeType(
INamedType namedType,
Expand Down Expand Up @@ -136,7 +137,7 @@ private static IEnumerable<INamedType> GetRelevantTypes(ISchema schema)

List<DirectiveNode>? directiveNodes = null;

foreach (IDirective directive in directives)
foreach (var directive in directives)
{
if (context.DirectiveNames.Contains(directive.Name))
{
Expand Down Expand Up @@ -167,8 +168,8 @@ private static bool IncludeField(IOutputField field)

private static bool IsApolloFederationType(INamedType type)
=> type is EntityType or ServiceType ||
type.Name.Equals(WellKnownTypeNames.Any) ||
type.Name.Equals(WellKnownTypeNames.FieldSet);
type.Name.EqualsOrdinal(WellKnownTypeNames.Any) ||
type.Name.EqualsOrdinal(WellKnownTypeNames.FieldSet);

private static bool IsBuiltInType(INamedType type) =>
IntrospectionTypes.IsIntrospectionType(type.Name) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ private void CompleteReferenceResolver(ObjectTypeDefinition typeDef)
else
{
var expressions = new Stack<(Expression Condition, Expression Execute)>();
ParameterExpression context = Expression.Parameter(typeof(IResolverContext));
var context = Expression.Parameter(typeof(IResolverContext));

foreach (ReferenceResolverDefinition resolverDef in resolvers)
foreach (var resolverDef in resolvers)
{
Expression required = Expression.Constant(resolverDef.Required);
Expression resolver = Expression.Constant(resolverDef.Resolver);
Expand All @@ -126,7 +126,7 @@ private void CompleteReferenceResolver(ObjectTypeDefinition typeDef)
}

Expression current = Expression.Call(_invalid, context);
ParameterExpression variable = Expression.Variable(typeof(ValueTask<object?>));
var variable = Expression.Variable(typeof(ValueTask<object?>));

while (expressions.Count > 0)
{
Expand Down Expand Up @@ -185,11 +185,11 @@ private void CompleteReferenceResolver(ObjectTypeDefinition typeDef)
{
if (objectType.RuntimeType != typeof(object))
{
IDescriptorContext descriptorContext = discoveryContext.DescriptorContext;
ITypeInspector typeInspector = discoveryContext.TypeInspector;
var descriptorContext = discoveryContext.DescriptorContext;
var typeInspector = discoveryContext.TypeInspector;
var descriptor = ObjectTypeDescriptor.From(descriptorContext, objectTypeDefinition);

foreach (MethodInfo possibleReferenceResolver in
foreach (var possibleReferenceResolver in
objectType.RuntimeType.GetMethods(BindingFlags.Static | BindingFlags.Public))
{
if (possibleReferenceResolver.IsDefined(typeof(ReferenceResolverAttribute)))
Expand All @@ -210,7 +210,7 @@ private void CompleteReferenceResolver(ObjectTypeDefinition typeDef)
ObjectTypeDefinition objectTypeDefinition)
{
if (objectTypeDefinition.Directives.Any(
d => d.Reference is NameDirectiveReference { Name.Value: WellKnownTypeNames.Key }) ||
d => d.Reference is NameDirectiveReference { Name: WellKnownTypeNames.Key }) ||
objectTypeDefinition.Fields.Any(f => f.ContextData.ContainsKey(WellKnownTypeNames.Key)))
{
_entityTypes.Add(objectType);
Expand All @@ -229,7 +229,7 @@ private void CompleteReferenceResolver(ObjectTypeDefinition typeDef)
IReadOnlyList<ObjectFieldDefinition> fields = objectTypeDefinition.Fields;
var fieldSet = new StringBuilder();

foreach (ObjectFieldDefinition? fieldDefinition in fields)
foreach (var fieldDefinition in fields)
{
if (fieldDefinition.ContextData.ContainsKey(KeyMarker))
{
Expand All @@ -247,7 +247,7 @@ private void CompleteReferenceResolver(ObjectTypeDefinition typeDef)

// register dependency to the key directive so that it is completed before
// we complete this type.
foreach (DirectiveDefinition directiveDefinition in objectTypeDefinition.Directives)
foreach (var directiveDefinition in objectTypeDefinition.Directives)
{
discoveryContext.Dependencies.Add(
new TypeDependency(
Expand All @@ -270,7 +270,7 @@ private void CompleteReferenceResolver(ObjectTypeDefinition typeDef)
if (completionContext.Type is EntityType &&
definition is UnionTypeDefinition unionTypeDefinition)
{
foreach (ObjectType objectType in _entityTypes)
foreach (var objectType in _entityTypes)
{
unionTypeDefinition.Types.Add(TypeReference.Create(objectType));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public FieldSetType() : this(WellKnownTypeNames.FieldSet)
/// <param name="bind">
/// Defines if this scalar shall bind implicitly to <see cref="SelectionSetNode"/>.
/// </param>
public FieldSetType(NameString name, BindingBehavior bind = BindingBehavior.Explicit)
public FieldSetType(string name, BindingBehavior bind = BindingBehavior.Explicit)
: base(name, bind)
{
Description = FederationResources.FieldsetType_Description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ internal static class ArgumentParser
var current = path[i];

if (type is not IComplexOutputType complexType ||
!complexType.Fields.TryGetField(current, out IOutputField? field))
!complexType.Fields.TryGetField(current, out var field))
{
break;
}

foreach (ObjectFieldNode fieldValue in ((ObjectValueNode)valueNode).Fields)
foreach (var fieldValue in ((ObjectValueNode)valueNode).Fields)
{
if (fieldValue.Name.Value.EqualsOrdinal(current))
{
Expand Down Expand Up @@ -118,7 +118,7 @@ private static bool Matches(IValueNode valueNode, string[] path, int i)
case SyntaxKind.ObjectValue:
var current = path[i];

foreach (ObjectFieldNode fieldValue in ((ObjectValueNode)valueNode).Fields)
foreach (var fieldValue in ((ObjectValueNode)valueNode).Fields)
{
if (fieldValue.Name.Value.EqualsOrdinal(current))
{
Expand Down

0 comments on commit 80350d8

Please sign in to comment.