Skip to content

Commit 133a3c0

Browse files
authored
Split Cookie Crumble into multiple libraries (#7774)
1 parent c477e13 commit 133a3c0

File tree

652 files changed

+911
-769
lines changed

Some content is hidden

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

652 files changed

+911
-769
lines changed

src/CookieCrumble/CookieCrumble.sln

+50-36
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,50 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30114.105
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2465C122-714C-4D0A-A24D-D9C22A25D73A}"
7-
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble", "src\CookieCrumble\CookieCrumble.csproj", "{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}"
9-
EndProject
10-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{EB8F1D90-60D6-48FA-9744-D4180A0E4AC0}"
11-
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble.Tests", "test\CookieCrumble.Tests\CookieCrumble.Tests.csproj", "{844E7501-7ED6-4548-8E99-D8E50D4F39A4}"
13-
EndProject
14-
Global
15-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16-
Debug|Any CPU = Debug|Any CPU
17-
Release|Any CPU = Release|Any CPU
18-
EndGlobalSection
19-
GlobalSection(SolutionProperties) = preSolution
20-
HideSolutionNode = FALSE
21-
EndGlobalSection
22-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23-
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24-
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
25-
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
26-
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}.Release|Any CPU.Build.0 = Release|Any CPU
27-
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28-
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
29-
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
30-
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Release|Any CPU.Build.0 = Release|Any CPU
31-
EndGlobalSection
32-
GlobalSection(NestedProjects) = preSolution
33-
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0} = {2465C122-714C-4D0A-A24D-D9C22A25D73A}
34-
{844E7501-7ED6-4548-8E99-D8E50D4F39A4} = {EB8F1D90-60D6-48FA-9744-D4180A0E4AC0}
35-
EndGlobalSection
36-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30114.105
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2465C122-714C-4D0A-A24D-D9C22A25D73A}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble", "src\CookieCrumble\CookieCrumble.csproj", "{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble.Fusion", "src\CookieCrumble.Fusion\CookieCrumble.Fusion.csproj", "{E6862862-986B-4A67-8703-49C70051DBDC}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble.HotChocolate", "src\CookieCrumble.HotChocolate\CookieCrumble.HotChocolate.csproj", "{9B57E4BC-E62A-4B7B-94FB-462C5F92D35B}"
13+
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{EB8F1D90-60D6-48FA-9744-D4180A0E4AC0}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble.Tests", "test\CookieCrumble.Tests\CookieCrumble.Tests.csproj", "{844E7501-7ED6-4548-8E99-D8E50D4F39A4}"
17+
EndProject
18+
Global
19+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
20+
Debug|Any CPU = Debug|Any CPU
21+
Release|Any CPU = Release|Any CPU
22+
EndGlobalSection
23+
GlobalSection(SolutionProperties) = preSolution
24+
HideSolutionNode = FALSE
25+
EndGlobalSection
26+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
27+
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{E6862862-986B-4A67-8703-49C70051DBDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{E6862862-986B-4A67-8703-49C70051DBDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{E6862862-986B-4A67-8703-49C70051DBDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{E6862862-986B-4A67-8703-49C70051DBDC}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{9B57E4BC-E62A-4B7B-94FB-462C5F92D35B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{9B57E4BC-E62A-4B7B-94FB-462C5F92D35B}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{9B57E4BC-E62A-4B7B-94FB-462C5F92D35B}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{9B57E4BC-E62A-4B7B-94FB-462C5F92D35B}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Release|Any CPU.Build.0 = Release|Any CPU
43+
EndGlobalSection
44+
GlobalSection(NestedProjects) = preSolution
45+
{8E71FA9B-8352-4675-A9B4-A934E40AF9E0} = {2465C122-714C-4D0A-A24D-D9C22A25D73A}
46+
{E6862862-986B-4A67-8703-49C70051DBDC} = {2465C122-714C-4D0A-A24D-D9C22A25D73A}
47+
{9B57E4BC-E62A-4B7B-94FB-462C5F92D35B} = {2465C122-714C-4D0A-A24D-D9C22A25D73A}
48+
{844E7501-7ED6-4548-8E99-D8E50D4F39A4} = {EB8F1D90-60D6-48FA-9744-D4180A0E4AC0}
49+
EndGlobalSection
50+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<AssemblyName>CookieCrumble.Fusion</AssemblyName>
5+
<RootNamespace>CookieCrumble.Fusion</RootNamespace>
6+
<IsPackable>true</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\CookieCrumble\CookieCrumble.csproj" />
11+
<ProjectReference Include="..\..\..\HotChocolate\Fusion\src\Core\HotChocolate.Fusion.csproj" />
12+
</ItemGroup>
13+
14+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using CookieCrumble.Fusion.Formatters;
2+
3+
namespace CookieCrumble.Fusion;
4+
5+
public static class CookieCrumbleFusion
6+
{
7+
public static void Initialize()
8+
{
9+
Snapshot.TryRegisterFormatter(SnapshotValueFormatters.QueryPlan);
10+
}
11+
}

src/CookieCrumble/src/CookieCrumble/Formatters/QueryPlanSnapshotValueFormatter.cs src/CookieCrumble/src/CookieCrumble.Fusion/Formatters/QueryPlanSnapshotValueFormatter.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using System.Buffers;
2+
using CookieCrumble.Formatters;
23
using HotChocolate.Fusion.Execution.Nodes;
34

4-
namespace CookieCrumble.Formatters;
5+
namespace CookieCrumble.Fusion.Formatters;
56

67
internal sealed class QueryPlanSnapshotValueFormatter() : SnapshotValueFormatter<QueryPlan>("json")
78
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using CookieCrumble.Formatters;
2+
3+
namespace CookieCrumble.Fusion.Formatters;
4+
5+
/// <summary>
6+
/// Provides access to well-known snapshot value formatters.
7+
/// </summary>
8+
public static class SnapshotValueFormatters
9+
{
10+
public static ISnapshotValueFormatter QueryPlan { get; } =
11+
new QueryPlanSnapshotValueFormatter();
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<AssemblyName>CookieCrumble.HotChocolate</AssemblyName>
5+
<RootNamespace>CookieCrumble.HotChocolate</RootNamespace>
6+
<IsPackable>true</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\CookieCrumble\CookieCrumble.csproj" />
11+
<ProjectReference Include="..\..\..\HotChocolate\AspNetCore\src\Transport.Abstractions\HotChocolate.Transport.Abstractions.csproj" />
12+
<ProjectReference Include="..\..\..\HotChocolate\AspNetCore\src\Transport.Http\HotChocolate.Transport.Http.csproj" />
13+
<ProjectReference Include="..\..\..\HotChocolate\Core\src\Execution\HotChocolate.Execution.csproj" />
14+
<ProjectReference Include="..\..\..\HotChocolate\Core\src\Types\HotChocolate.Types.csproj" />
15+
<ProjectReference Include="..\..\..\HotChocolate\Language\src\Language.SyntaxTree\HotChocolate.Language.SyntaxTree.csproj" />
16+
</ItemGroup>
17+
18+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using CookieCrumble.HotChocolate.Formatters;
2+
3+
namespace CookieCrumble.HotChocolate;
4+
5+
public static class CookieCrumbleHotChocolate
6+
{
7+
public static void Initialize()
8+
{
9+
Snapshot.TryRegisterFormatter(SnapshotValueFormatters.ExecutionResult);
10+
Snapshot.TryRegisterFormatter(SnapshotValueFormatters.GraphQL);
11+
Snapshot.TryRegisterFormatter(SnapshotValueFormatters.GraphQLHttp);
12+
Snapshot.TryRegisterFormatter(SnapshotValueFormatters.OperationResult);
13+
Snapshot.TryRegisterFormatter(SnapshotValueFormatters.Schema);
14+
Snapshot.TryRegisterFormatter(SnapshotValueFormatters.SchemaError);
15+
}
16+
}

src/CookieCrumble/src/CookieCrumble/Extensions/CommonTestExtensions.cs src/CookieCrumble/src/CookieCrumble.HotChocolate/Extensions/CommonTestExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using HotChocolate.Execution.Configuration;
33
using Microsoft.Extensions.DependencyInjection;
44

5-
namespace CookieCrumble;
5+
namespace CookieCrumble.HotChocolate;
66

77
public static class CommonTestExtensions
88
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using CookieCrumble.HotChocolate.Formatters;
2+
using HotChocolate;
3+
using HotChocolate.Execution;
4+
using HotChocolate.Language;
5+
using CoreFormatters = CookieCrumble.Formatters.SnapshotValueFormatters;
6+
7+
namespace CookieCrumble.HotChocolate;
8+
9+
public static class SnapshotExtensions
10+
{
11+
public static void MatchSnapshot(
12+
this ISyntaxNode? value,
13+
string? postFix = null)
14+
=> Snapshot.Match(
15+
value,
16+
postFix,
17+
extension: ".graphql",
18+
formatter: SnapshotValueFormatters.GraphQL);
19+
20+
public static void MatchSnapshot(
21+
this ISchema? value,
22+
string? postFix = null)
23+
=> Snapshot.Match(
24+
value,
25+
postFix,
26+
extension: ".graphql",
27+
formatter: SnapshotValueFormatters.Schema);
28+
29+
public static void MatchSnapshot(
30+
this IExecutable? value,
31+
string? postFix = null)
32+
=> Snapshot.Match(
33+
value,
34+
postFix,
35+
formatter: CoreFormatters.PlainText);
36+
37+
public static Snapshot AddResult(
38+
this Snapshot snapshot,
39+
IExecutionResult result,
40+
string? name = null)
41+
{
42+
if (result.ContextData is null)
43+
{
44+
snapshot.Add(result.ToJson(), name);
45+
return snapshot;
46+
}
47+
48+
snapshot.Add(
49+
result.ToJson(),
50+
string.IsNullOrEmpty(name)
51+
? "Result:"
52+
: $"{name} Result:");
53+
54+
if (result.ContextData.TryGetValue("query", out var queryResult) &&
55+
queryResult is string queryString &&
56+
!string.IsNullOrWhiteSpace(queryString))
57+
{
58+
snapshot.Add(
59+
queryString,
60+
string.IsNullOrEmpty(name)
61+
? "Query:"
62+
: $"{name} Query:",
63+
CoreFormatters.PlainText);
64+
}
65+
66+
if (result.ContextData.TryGetValue("sql", out var sql))
67+
{
68+
snapshot.Add(
69+
sql,
70+
string.IsNullOrEmpty(name)
71+
? "SQL:"
72+
: $"{name} SQL:",
73+
CoreFormatters.PlainText);
74+
}
75+
76+
if (result.ContextData.TryGetValue("expression", out var expression))
77+
{
78+
snapshot.Add(
79+
expression,
80+
string.IsNullOrEmpty(name)
81+
? "Expression:"
82+
: $"{name} Expression:",
83+
CoreFormatters.PlainText);
84+
}
85+
86+
if (result.ContextData.TryGetValue("ex", out var exception))
87+
{
88+
snapshot.Add(exception, "Exception:");
89+
}
90+
91+
return snapshot;
92+
}
93+
}

src/CookieCrumble/src/CookieCrumble/Formatters/ExecutionResultSnapshotValueFormatter.cs src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/ExecutionResultSnapshotValueFormatter.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using System.Buffers;
22
using System.Text.Json;
33
using System.Text.Json.Nodes;
4+
using CookieCrumble.Formatters;
45
using HotChocolate;
56
using HotChocolate.Execution;
67

7-
namespace CookieCrumble.Formatters;
8+
namespace CookieCrumble.HotChocolate.Formatters;
89

910
internal sealed class ExecutionResultSnapshotValueFormatter
1011
: SnapshotValueFormatter<IExecutionResult>

src/CookieCrumble/src/CookieCrumble/Formatters/GraphQLHttpResponseFormatter.cs src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/GraphQLHttpResponseFormatter.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
using System.Buffers;
22
using System.Net.Http.Headers;
33
using System.Text.Json;
4+
using CookieCrumble.Formatters;
5+
using HotChocolate.Transport.Http;
46
using Microsoft.AspNetCore.WebUtilities;
57

6-
namespace CookieCrumble.Formatters;
8+
namespace CookieCrumble.HotChocolate.Formatters;
79

8-
internal sealed class GraphQLHttpResponseFormatter : SnapshotValueFormatter<HttpResponseMessage>
10+
internal sealed class GraphQLHttpResponseFormatter : SnapshotValueFormatter<GraphQLHttpResponse>
911
{
10-
protected override void Format(IBufferWriter<byte> snapshot, HttpResponseMessage value)
12+
protected override void Format(IBufferWriter<byte> snapshot, GraphQLHttpResponse value)
1113
{
12-
var contentType = value.Content.Headers.ContentType;
14+
var contentType = value.ContentHeaders.ContentType;
1315

1416
if (string.Equals(contentType?.MediaType, "multipart/mixed", StringComparison.Ordinal))
1517
{
1618
var boundary = contentType!.Parameters.First(
1719
t => string.Equals(t.Name, "boundary", StringComparison.Ordinal));
18-
FormatStreamAsync(snapshot, boundary, value.Content.ReadAsStream()).Wait();
20+
FormatStreamAsync(snapshot, boundary, value.HttpResponseMessage.Content.ReadAsStream()).Wait();
1921
}
2022
}
2123

src/CookieCrumble/src/CookieCrumble/Formatters/GraphQLSnapshotValueFormatter.cs src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/GraphQLSnapshotValueFormatter.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using System.Buffers;
2+
using CookieCrumble.Formatters;
23
using HotChocolate.Language;
34
using HotChocolate.Language.Utilities;
45

5-
namespace CookieCrumble.Formatters;
6+
namespace CookieCrumble.HotChocolate.Formatters;
67

78
internal sealed class GraphQLSnapshotValueFormatter : SnapshotValueFormatter<ISyntaxNode>
89
{

src/CookieCrumble/src/CookieCrumble/Formatters/OperationResultSnapshotValueFormatter.cs src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/OperationResultSnapshotValueFormatter.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using System.Buffers;
22
using System.Text.Json;
3+
using CookieCrumble.Formatters;
34
using HotChocolate.Transport;
45

5-
namespace CookieCrumble.Formatters;
6+
namespace CookieCrumble.HotChocolate.Formatters;
67

78
internal sealed class OperationResultSnapshotValueFormatter : SnapshotValueFormatter<OperationResult>
89
{

src/CookieCrumble/src/CookieCrumble/Formatters/SchemaErrorSnapshotValueFormatter.cs src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/SchemaErrorSnapshotValueFormatter.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using System.Buffers;
2+
using CookieCrumble.Formatters;
23
using HotChocolate;
34

4-
namespace CookieCrumble.Formatters;
5+
namespace CookieCrumble.HotChocolate.Formatters;
56

67
internal sealed class SchemaErrorSnapshotValueFormatter
78
: SnapshotValueFormatter<ISchemaError[]>

src/CookieCrumble/src/CookieCrumble/Formatters/SchemaSnapshotValueFormatter.cs src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/SchemaSnapshotValueFormatter.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using System.Buffers;
2+
using CookieCrumble.Formatters;
23
using HotChocolate;
34

4-
namespace CookieCrumble.Formatters;
5+
namespace CookieCrumble.HotChocolate.Formatters;
56

67
internal sealed class SchemaSnapshotValueFormatter() : SnapshotValueFormatter<ISchema>("graphql")
78
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using CookieCrumble.Formatters;
2+
3+
namespace CookieCrumble.HotChocolate.Formatters;
4+
5+
/// <summary>
6+
/// Provides access to well-known snapshot value formatters.
7+
/// </summary>
8+
public static class SnapshotValueFormatters
9+
{
10+
public static ISnapshotValueFormatter ExecutionResult { get; } =
11+
new ExecutionResultSnapshotValueFormatter();
12+
13+
public static ISnapshotValueFormatter GraphQL { get; } =
14+
new GraphQLSnapshotValueFormatter();
15+
16+
public static ISnapshotValueFormatter GraphQLHttp { get; } =
17+
new GraphQLHttpResponseFormatter();
18+
19+
public static ISnapshotValueFormatter OperationResult { get; } =
20+
new OperationResultSnapshotValueFormatter();
21+
22+
public static ISnapshotValueFormatter Schema { get; } =
23+
new SchemaSnapshotValueFormatter();
24+
25+
public static ISnapshotValueFormatter SchemaError { get; } =
26+
new SchemaErrorSnapshotValueFormatter();
27+
}

src/CookieCrumble/src/CookieCrumble/CookieCrumble.csproj

-7
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,4 @@
1414
<PackageReference Include="Xunit" />
1515
</ItemGroup>
1616

17-
<ItemGroup>
18-
<ProjectReference Include="..\..\..\HotChocolate\Core\src\Core\HotChocolate.Core.csproj" />
19-
<ProjectReference Include="..\..\..\HotChocolate\AspNetCore\src\AspNetCore\HotChocolate.AspNetCore.csproj" />
20-
<ProjectReference Include="..\..\..\HotChocolate\AspNetCore\src\Transport.Abstractions\HotChocolate.Transport.Abstractions.csproj" />
21-
<ProjectReference Include="..\..\..\HotChocolate\Fusion\src\Core\HotChocolate.Fusion.csproj" />
22-
</ItemGroup>
23-
2417
</Project>

0 commit comments

Comments
 (0)