Skip to content

Commit

Permalink
Add Subscribe Resolver Compiler (#1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Jan 25, 2020
1 parent 2bd2f41 commit c9f5e60
Show file tree
Hide file tree
Showing 48 changed files with 1,901 additions and 340 deletions.
75 changes: 37 additions & 38 deletions src/Core/Types.Tests/Resolvers/ResolverPropertyGeneratorTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Immutable;
using System;
using System.Collections.Generic;
using System;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using System.Threading;
Expand All @@ -10,7 +10,6 @@
using HotChocolate.Types;
using Moq;
using Xunit;
using HotChocolate.Execution;

namespace HotChocolate.Resolvers.Expressions
{
Expand All @@ -27,7 +26,7 @@ public async Task Compile_TaskObjMethod_NoParams_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -48,7 +47,7 @@ public async Task Compile_TaskStringMethod_NoParams_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -70,7 +69,7 @@ public async Task Compile_TaskStringMethod_WithParams_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -92,7 +91,7 @@ public async Task Compile_ObjMethod_NoParams_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -113,7 +112,7 @@ public async Task Compile_StringMethod_NoParams_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -135,7 +134,7 @@ public async Task Compile_StringMethod_WithParams_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -158,7 +157,7 @@ public async Task Compile_ObjTaskProperty_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -180,7 +179,7 @@ public async Task Compile_StringTaskProperty_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -202,7 +201,7 @@ public async Task Compile_StringProperty_SourceResolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -224,7 +223,7 @@ public async Task Compile_TaskObjMethod_NoParams_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -247,7 +246,7 @@ public async Task Compile_TaskStringMethod_NoParams_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -271,7 +270,7 @@ public async Task Compile_TaskStringMethod_WithParams_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -295,7 +294,7 @@ public async Task Compile_ObjMethod_NoParams_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -318,7 +317,7 @@ public async Task Compile_StringMethod_NoParams_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -342,7 +341,7 @@ public async Task Compile_StringMethod_WithParams_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -367,7 +366,7 @@ public async Task Compile_ObjTaskProperty_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -391,7 +390,7 @@ public async Task Compile_StringTaskProperty_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -415,7 +414,7 @@ public async Task Compile_StringProperty_Resolver()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -438,7 +437,7 @@ public async Task Compile_Arguments_CancellationToken()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -463,7 +462,7 @@ public async Task Compile_Arguments_ResolverContext()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -486,7 +485,7 @@ public async Task Compile_Arguments_EventMessage()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -512,7 +511,7 @@ public async Task Compile_Arguments_FieldSelection()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand Down Expand Up @@ -543,7 +542,7 @@ public async Task Compile_Arguments_ObjectType()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand Down Expand Up @@ -573,7 +572,7 @@ public async Task Compile_Arguments_Operation()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand Down Expand Up @@ -606,7 +605,7 @@ public async Task Compile_Arguments_ObjectField()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand Down Expand Up @@ -636,7 +635,7 @@ public async Task Compile_Arguments_IOutputField()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand Down Expand Up @@ -666,7 +665,7 @@ public async Task Compile_Arguments_Document()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -693,7 +692,7 @@ public async Task Compile_Arguments_Schema()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand Down Expand Up @@ -722,7 +721,7 @@ public async Task Compile_Arguments_Service()
new FieldMember("A", "b", resolverMember));

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand Down Expand Up @@ -751,7 +750,7 @@ public async Task Compile_Arguments_ContextData()
};

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -775,7 +774,7 @@ public async Task Compile_Arguments_ContextData_DefaultValue()
var contextData = new Dictionary<string, object>();

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -799,7 +798,7 @@ public void Compile_Arguments_ContextData_NotExists()
var contextData = new Dictionary<string, object>();

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -824,7 +823,7 @@ public async Task Compile_Arguments_ScopedContextData()
.SetItem("foo", "bar");

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -848,7 +847,7 @@ public async Task Compile_Arguments_ScopedContextData_DefaultValue()
var contextData = ImmutableDictionary<string, object>.Empty;

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand All @@ -872,7 +871,7 @@ public void Compile_Arguments_ScopedContextData_NotExists()
var contextData = ImmutableDictionary<string, object>.Empty;

// act
var compiler = new ResolverCompiler();
var compiler = new ResolveCompiler();
FieldResolver resolver = compiler.Compile(resolverDescriptor);

// assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public void ResolverTypesDoNotOverwriteSchemaTypes()
// arrange
var descriptor = ObjectFieldDescriptor.New(
Context,
typeof(ObjectField).GetProperty("Arguments"));
typeof(ObjectField).GetProperty("Arguments"),
typeof(ObjectField));

// act
descriptor
Expand All @@ -114,7 +115,8 @@ public void OverwriteName()
// arrange
var descriptor = ObjectFieldDescriptor.New(
Context,
typeof(ObjectField).GetProperty("Arguments"));
typeof(ObjectField).GetProperty("Arguments"),
typeof(ObjectField));

// act
descriptor.Name("args");
Expand All @@ -130,7 +132,8 @@ public void SetDescription()
string expectedDescription = Guid.NewGuid().ToString();
var descriptor = ObjectFieldDescriptor.New(
Context,
typeof(ObjectField).GetProperty("Arguments"));
typeof(ObjectField).GetProperty("Arguments"),
typeof(ObjectField));

// act
descriptor.Description(expectedDescription);
Expand All @@ -147,7 +150,8 @@ public void SetResolverAndInferTypeFromResolver()
var descriptor =
ObjectFieldDescriptor.New(
Context,
typeof(ObjectField).GetProperty("Arguments"));
typeof(ObjectField).GetProperty("Arguments"),
typeof(ObjectField));

// act
descriptor.Resolver(() => "ThisIsAString");
Expand All @@ -173,7 +177,8 @@ public void SetResolverAndInferTypeIsAlwaysRecognisedAsDotNetType()
var descriptor =
ObjectFieldDescriptor.New(
Context,
typeof(ObjectField).GetProperty("Arguments"));
typeof(ObjectField).GetProperty("Arguments"),
typeof(ObjectField));

// act
descriptor
Expand All @@ -199,6 +204,7 @@ public void ResolverTypeIsSet()
ObjectFieldDescriptor.New(
Context,
typeof(ObjectField).GetProperty("Arguments"),
typeof(ObjectField),
typeof(string));

// assert
Expand Down
Loading

0 comments on commit c9f5e60

Please sign in to comment.