Skip to content

Commit e491db2

Browse files
committed
Fixed DataLoader does not work with a class resolver for interface types. (#8117)
1 parent 6473ae8 commit e491db2

File tree

8 files changed

+150
-1
lines changed

8 files changed

+150
-1
lines changed

src/All.slnx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@
128128
<Project Path="HotChocolate/Core/test/Utilities/HotChocolate.Tests.Utilities.csproj" />
129129
<Project Path="HotChocolate/Core/test/Validation.Tests/HotChocolate.Validation.Tests.csproj" />
130130
</Folder>
131+
<Folder Name="/HotChocolate/Core/test/Types.Analyzer.Integration.Tests/">
132+
<Project Path="HotChocolate/Core/test/Types.Analyzer.Integration.Tests/HotChocolate.Types.Analyzers.Tests.csproj" />
133+
</Folder>
131134
<Folder Name="/HotChocolate/CostAnalysis/" />
132135
<Folder Name="/HotChocolate/CostAnalysis/src/">
133136
<Project Path="HotChocolate/CostAnalysis/src/CostAnalysis/HotChocolate.CostAnalysis.csproj" />

src/HotChocolate/Core/HotChocolate.Core.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Features.Tests
147147
EndProject
148148
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Execution.Projections", "src\Execution.Projections\HotChocolate.Execution.Projections.csproj", "{68726F89-B254-424B-BE17-AC9312484464}"
149149
EndProject
150+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Types.Analyzer.Integration.Tests", "Types.Analyzer.Integration.Tests", "{BB753F80-E4F3-4510-2AE6-4DF7F004941D}"
151+
EndProject
152+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Types.Analyzers.Tests", "test\Types.Analyzer.Integration.Tests\HotChocolate.Types.Analyzers.Tests.csproj", "{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}"
153+
EndProject
150154
Global
151155
GlobalSection(SolutionConfigurationPlatforms) = preSolution
152156
Debug|Any CPU = Debug|Any CPU
@@ -985,6 +989,18 @@ Global
985989
{68726F89-B254-424B-BE17-AC9312484464}.Release|x64.Build.0 = Release|Any CPU
986990
{68726F89-B254-424B-BE17-AC9312484464}.Release|x86.ActiveCfg = Release|Any CPU
987991
{68726F89-B254-424B-BE17-AC9312484464}.Release|x86.Build.0 = Release|Any CPU
992+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
993+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Debug|Any CPU.Build.0 = Debug|Any CPU
994+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Debug|x64.ActiveCfg = Debug|Any CPU
995+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Debug|x64.Build.0 = Debug|Any CPU
996+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Debug|x86.ActiveCfg = Debug|Any CPU
997+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Debug|x86.Build.0 = Debug|Any CPU
998+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Release|Any CPU.ActiveCfg = Release|Any CPU
999+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Release|Any CPU.Build.0 = Release|Any CPU
1000+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Release|x64.ActiveCfg = Release|Any CPU
1001+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Release|x64.Build.0 = Release|Any CPU
1002+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Release|x86.ActiveCfg = Release|Any CPU
1003+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C}.Release|x86.Build.0 = Release|Any CPU
9881004
EndGlobalSection
9891005
GlobalSection(SolutionProperties) = preSolution
9901006
HideSolutionNode = FALSE
@@ -1059,6 +1075,8 @@ Global
10591075
{669FA147-3B41-4841-921A-55B019C3AF26} = {37B9D3B1-CA34-4720-9A0B-CFF1E64F52C2}
10601076
{EA77D317-8767-4DDE-8038-820D582C52D6} = {7462D089-D350-44D6-8131-896D949A65B7}
10611077
{68726F89-B254-424B-BE17-AC9312484464} = {37B9D3B1-CA34-4720-9A0B-CFF1E64F52C2}
1078+
{BB753F80-E4F3-4510-2AE6-4DF7F004941D} = {7462D089-D350-44D6-8131-896D949A65B7}
1079+
{5C9FBB6B-2CD6-4812-9CD7-BFA36734D55C} = {BB753F80-E4F3-4510-2AE6-4DF7F004941D}
10621080
EndGlobalSection
10631081
GlobalSection(ExtensibilityGlobals) = postSolution
10641082
SolutionGuid = {E4D94C77-6657-4630-9D42-0A9AC5153A1B}

src/HotChocolate/Core/src/Types/Types/Descriptors/Definitions/InterfaceFieldDefinition.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ public class InterfaceFieldDefinition : OutputFieldDefinitionBase
2424
/// <summary>
2525
/// Initializes a new instance of <see cref="ObjectTypeDefinition"/>.
2626
/// </summary>
27-
public InterfaceFieldDefinition() { }
27+
public InterfaceFieldDefinition()
28+
{
29+
IsParallelExecutable = true;
30+
}
2831

2932
/// <summary>
3033
/// Initializes a new instance of <see cref="ObjectTypeDefinition"/>.
@@ -37,6 +40,7 @@ public InterfaceFieldDefinition(
3740
Name = name.EnsureGraphQLName();
3841
Description = description;
3942
Type = type;
43+
IsParallelExecutable = true;
4044
}
4145

4246
/// <summary>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<IsPackable>false</IsPackable>
5+
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);HotChocolate.Execution.Generated</InterceptorsPreviewNamespaces>
6+
7+
<!--EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
8+
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath-->
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<AssemblyName>HotChocolate.Types.Analyzers.Tests</AssemblyName>
13+
<RootNamespace>HotChocolate.Types</RootNamespace>
14+
<NoWarn>$(NoWarn);GD0001</NoWarn>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\..\..\..\GreenDonut\src\GreenDonut.Data.Abstractions\GreenDonut.Data.Abstractions.csproj" />
19+
<ProjectReference Include="..\..\..\..\GreenDonut\src\GreenDonut.Data.EntityFramework\GreenDonut.Data.EntityFramework.csproj" />
20+
<ProjectReference Include="..\..\..\..\GreenDonut\src\GreenDonut.Data.Primitives\GreenDonut.Data.Primitives.csproj" />
21+
<ProjectReference Include="..\..\..\..\GreenDonut\src\GreenDonut.Data\GreenDonut.Data.csproj" />
22+
<ProjectReference Include="..\..\..\AspNetCore\src\AspNetCore\HotChocolate.AspNetCore.csproj" />
23+
<ProjectReference Include="..\..\src\Core\HotChocolate.Core.csproj" />
24+
<ProjectReference Include="..\Utilities\HotChocolate.Tests.Utilities.csproj" />
25+
<ProjectReference Include="..\..\src\Types.Analyzers\HotChocolate.Types.Analyzers.csproj" OutputItemType="Analyzer" />
26+
<ProjectReference Include="..\..\..\Data\src\Data\HotChocolate.Data.csproj" />
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<PackageReference Include="Basic.Reference.Assemblies.Net80" />
31+
<PackageReference Include="Basic.Reference.Assemblies.Net90" />
32+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<None Update="$(MSBuildProjectDirectory)\__resources__\*.*">
37+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
38+
</None>
39+
<None Update="$(MSBuildProjectDirectory)\xunit.runner.json">
40+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
41+
</None>
42+
</ItemGroup>
43+
44+
</Project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using HotChocolate.Execution;
2+
using HotChocolate.Tests;
3+
using Microsoft.Extensions.DependencyInjection;
4+
5+
namespace HotChocolate.Types;
6+
7+
public class InterfaceTests
8+
{
9+
[Fact]
10+
public async Task Schema_Snapshot()
11+
{
12+
await new ServiceCollection()
13+
.AddGraphQLServer()
14+
.AddIntegrationTestTypes()
15+
.BuildSchemaAsync()
16+
.MatchSnapshotAsync();
17+
}
18+
19+
[Fact]
20+
public async Task Ensure_Interface_Resolvers_Are_ParallelExecutable()
21+
{
22+
var schema =
23+
await new ServiceCollection()
24+
.AddGraphQLServer()
25+
.AddIntegrationTestTypes()
26+
.BuildSchemaAsync();
27+
28+
Assert.True(
29+
schema.GetType<ObjectType>("Book")
30+
.Fields["kind"]
31+
.IsParallelExecutable,
32+
"Interface resolvers should be parallel executable");
33+
}
34+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using HotChocolate;
2+
3+
[assembly: Module("IntegrationTestTypes")]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace HotChocolate.Types;
2+
3+
[InterfaceType]
4+
public class Product
5+
{
6+
public required string Id { get; set; }
7+
}
8+
9+
[InterfaceType<Product>]
10+
public static partial class ProductType
11+
{
12+
public static string Kind() => "Product";
13+
}
14+
15+
[ObjectType]
16+
public class Book : Product
17+
{
18+
public required string Title { get; set; }
19+
}
20+
21+
[QueryType]
22+
public static partial class Query
23+
{
24+
public static Product GetProduct() => new Book { Id = "1", Title = "GraphQL in Action" };
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
schema {
2+
query: Query
3+
}
4+
5+
interface Product {
6+
kind: String!
7+
id: String!
8+
}
9+
10+
type Book implements Product {
11+
title: String!
12+
id: String!
13+
kind: String!
14+
}
15+
16+
type Query {
17+
product: Product!
18+
}

0 commit comments

Comments
 (0)