Skip to content

Commit 8809ac9

Browse files
committed
Merge branch 'main' into gai/migration-disable-format-check
2 parents 1a0cf1a + c2f8a94 commit 8809ac9

File tree

151 files changed

+4366
-2143
lines changed

Some content is hidden

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

151 files changed

+4366
-2143
lines changed

src/CookieCrumble/src/CookieCrumble/Snapshot.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,11 @@ private static bool MatchSnapshot(
505505
{
506506
if (OperatingSystem.IsWindows())
507507
{
508-
// Normalize escaped line endings
509-
after = after.Replace("\\r\\n", "\\n");
508+
// Normalize escaped line endings if the expected value does not explicitly contain them.
509+
if (!before.Contains("\\r\\n", StringComparison.Ordinal))
510+
{
511+
after = after.Replace("\\r\\n", "\\n");
512+
}
510513
}
511514

512515
var diff = InlineDiffBuilder.Diff(before, after);

src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetSchemaMiddlewareTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public async Task Download_GraphQL_Schema(string path)
5454

5555
// assert
5656
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
57+
response.Headers.Remove("ETag");
58+
response.Content.Headers.ContentLength = null;
5759

5860
response.MatchMarkdownSnapshot();
5961
}
@@ -81,6 +83,8 @@ public async Task Download_GraphQL_Schema_Slicing_Args_Enabled(string path)
8183

8284
// assert
8385
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
86+
response.Headers.Remove("ETag");
87+
response.Content.Headers.ContentLength = null;
8488

8589
response.MatchMarkdownSnapshot();
8690
}

src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_Schema.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
```text
44
Headers:
5-
ETag: "1-9lT+j9S1VOCU5XKHoaNVEuxjYrB+yk/yPGmxKIktwoY="
65
Cache-Control: public, must-revalidate, max-age=3600
76
Content-Type: application/graphql; charset=utf-8
87
Content-Disposition: attachment; filename="schema.graphql"
98
Last-Modified: Fri, 01 Jan 2021 00:00:00 GMT
10-
Content-Length: 7466
119
-------------------------->
1210
Status Code: OK
1311
-------------------------->

src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_Schema_Slicing_Args_Enabled.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
```text
44
Headers:
5-
ETag: "1-273kV/JyKVpBuGqgpSjbHzLG6jb6xKsQlr4kTrMaNmg="
65
Cache-Control: public, must-revalidate, max-age=3600
76
Content-Type: application/graphql; charset=utf-8
87
Content-Disposition: attachment; filename="schema.graphql"
98
Last-Modified: Fri, 01 Jan 2021 00:00:00 GMT
10-
Content-Length: 7398
119
-------------------------->
1210
Status Code: OK
1311
-------------------------->

src/HotChocolate/Core/src/Execution.Abstractions/ErrorBuilder.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,38 @@ public ErrorBuilder AddLocation(Location location)
8585
return this;
8686
}
8787

88+
/// <summary>
89+
/// Adds a GraphQL operation document location to the error, if the error does not already have a location.
90+
/// </summary>
91+
/// <param name="location">The location of the error.</param>
92+
/// <returns>The error builder.</returns>
93+
public ErrorBuilder TryAddLocation(Location location)
94+
{
95+
if (_locations == null || _locations.Count == 0)
96+
{
97+
_locations ??= [];
98+
_locations.Add(location);
99+
}
100+
101+
return this;
102+
}
103+
104+
/// <summary>
105+
/// Adds a GraphQL operation document location to the error.
106+
/// </summary>
107+
/// <param name="location">The location of the error.</param>
108+
/// <returns>The error builder.</returns>
109+
public ErrorBuilder TryAddLocation(Language.Location? location)
110+
{
111+
if (location != null && (_locations == null || _locations.Count == 0))
112+
{
113+
_locations ??= [];
114+
_locations.Add(new Location(location.Line, location.Column));
115+
}
116+
117+
return this;
118+
}
119+
88120
/// <summary>
89121
/// Clears the locations of the error.
90122
/// </summary>

src/HotChocolate/Core/src/Execution.Abstractions/ErrorBuilderExtensions.cs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,30 @@ public static class ErrorBuilderExtensions
1212
/// Sets the field coordinate of the error.
1313
/// </summary>
1414
/// <param name="builder">The error builder.</param>
15-
/// <param name="fieldCoordinate">The field coordinate.</param>
15+
/// <param name="coordinate">The field coordinate.</param>
1616
/// <returns>The error builder.</returns>
17-
public static ErrorBuilder SetFieldCoordinate(
17+
public static ErrorBuilder SetCoordinate(
1818
this ErrorBuilder builder,
19-
SchemaCoordinate fieldCoordinate)
19+
SchemaCoordinate coordinate)
2020
{
2121
ArgumentNullException.ThrowIfNull(builder);
2222

23-
return builder.SetExtension(nameof(fieldCoordinate), fieldCoordinate.ToString());
23+
return builder.SetExtension(nameof(coordinate), coordinate.ToString());
24+
}
25+
26+
/// <summary>
27+
/// Sets the input path of the error.
28+
/// </summary>
29+
/// <param name="builder">The error builder.</param>
30+
/// <param name="inputPath">The input path.</param>
31+
/// <returns>The error builder.</returns>
32+
public static ErrorBuilder SetInputPath(
33+
this ErrorBuilder builder,
34+
Path inputPath)
35+
{
36+
ArgumentNullException.ThrowIfNull(builder);
37+
38+
return builder.SetExtension(nameof(inputPath), inputPath);
2439
}
2540

2641
/// <summary>
@@ -58,6 +73,23 @@ public static ErrorBuilder AddLocation(this ErrorBuilder builder, ISyntaxNode no
5873
return builder;
5974
}
6075

76+
/// <summary>
77+
/// Adds a location to the error if the error does not already have a location.
78+
/// </summary>
79+
/// <param name="builder">The error builder.</param>
80+
/// <param name="node">The syntax node.</param>
81+
/// <returns>The error builder.</returns>
82+
public static ErrorBuilder TryAddLocation(this ErrorBuilder builder, ISyntaxNode? node)
83+
{
84+
if (node?.Location is null)
85+
{
86+
return builder;
87+
}
88+
89+
builder.TryAddLocation(new Location(node.Location.Line, node.Location.Column));
90+
return builder;
91+
}
92+
6193
/// <summary>
6294
/// Adds multiple locations to the error.
6395
/// </summary>

src/HotChocolate/Core/src/Execution/Configuration/RequestExecutorSetup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public sealed class RequestExecutorSetup
3333
/// </summary>
3434
public RequestExecutorOptions? RequestExecutorOptions { get; set; }
3535

36+
/// <summary>
37+
/// Gets or sets the time that the executor manager waits to dispose the schema services.
38+
/// </summary>
39+
public TimeSpan EvictionTimeout { get; set; } = TimeSpan.FromSeconds(30);
40+
3641
/// <summary>
3742
/// Gets the request executor options actions.
3843
/// This hook is invoke first in the schema creation process.
@@ -117,6 +122,7 @@ public void CopyTo(RequestExecutorSetup options)
117122
options._onBuildDocumentValidatorHooks.AddRange(_onBuildDocumentValidatorHooks);
118123
options._pipelineModifiers.AddRange(_pipelineModifiers);
119124
options._typeModules.AddRange(_typeModules);
125+
options.EvictionTimeout = EvictionTimeout;
120126

121127
if (DefaultPipelineFactory is not null)
122128
{

src/HotChocolate/Core/src/Execution/ErrorHelper.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,23 @@ internal static class ErrorHelper
1010
{
1111
public static IError ArgumentNonNullError(
1212
ArgumentNode argument,
13-
string responseName,
1413
ArgumentNonNullValidator.ValidationResult validationResult)
1514
{
1615
return ErrorBuilder.New()
1716
.SetMessage(
1817
ErrorHelper_ArgumentNonNullError_Message,
1918
argument.Name.Value)
2019
.AddLocation(argument)
21-
.SetExtension("responseName", responseName)
2220
.SetExtension("errorPath", validationResult.Path)
2321
.Build();
2422
}
2523

2624
public static IError ArgumentValueIsInvalid(
27-
ArgumentNode argument,
28-
string responseName,
25+
ArgumentNode? argument,
2926
GraphQLException exception)
3027
{
3128
return ErrorBuilder.FromError(exception.Errors[0])
32-
.AddLocation(argument)
33-
.SetExtension("responseName", responseName)
34-
.Build();
35-
}
36-
37-
public static IError ArgumentDefaultValueIsInvalid(
38-
string responseName,
39-
GraphQLException exception)
40-
{
41-
return ErrorBuilder.FromError(exception.Errors[0])
42-
.SetExtension("responseName", responseName)
29+
.TryAddLocation(argument)
4330
.Build();
4431
}
4532

@@ -49,7 +36,7 @@ public static IError InvalidLeafValue(
4936
Path path)
5037
{
5138
return ErrorBuilder.FromError(exception.Errors[0])
52-
.AddLocation(field)
39+
.TryAddLocation(field)
5340
.SetPath(path)
5441
.SetCode(ErrorCodes.Execution.CannotSerializeLeafValue)
5542
.Build();

src/HotChocolate/Core/src/Execution/HotChocolate.Execution.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<InternalsVisibleTo Include="HotChocolate.Execution.Projections" />
2525
<InternalsVisibleTo Include="HotChocolate.Execution.Tests" />
2626
<InternalsVisibleTo Include="HotChocolate.Fusion.Tests" />
27+
<InternalsVisibleTo Include="HotChocolate.Types.Tests" />
2728
<InternalsVisibleTo Include="HotChocolate.Fusion" />
2829
<InternalsVisibleTo Include="HotChocolate.Types.Mutations" />
2930
<InternalsVisibleTo Include="StrawberryShake.CodeGeneration" />
@@ -219,6 +220,15 @@
219220
<Compile Update="DependencyInjection\RequestExecutorBuilderExtensions.Services.cs">
220221
<DependentUpon>RequestExecutorBuilderExtensions.cs</DependentUpon>
221222
</Compile>
223+
<Compile Update="RequestExecutorManager.Events.cs">
224+
<DependentUpon>RequestExecutorManager.cs</DependentUpon>
225+
</Compile>
226+
<Compile Update="RequestExecutorManager.Hooks.cs">
227+
<DependentUpon>RequestExecutorManager.cs</DependentUpon>
228+
</Compile>
229+
<Compile Update="RequestExecutorManager.Warmup.cs">
230+
<DependentUpon>RequestExecutorManager.cs</DependentUpon>
231+
</Compile>
222232
</ItemGroup>
223233

224234
<ItemGroup>

src/HotChocolate/Core/src/Execution/Options/NodeIdSerializerOptions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using HotChocolate.Execution.Relay;
2-
using HotChocolate.Types.Relay;
32

43
namespace HotChocolate.Execution.Options;
54

0 commit comments

Comments
 (0)