Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed resolver compiler did not use the GraphQL argument name for fie…
…ld args. (#5736)
- Loading branch information
1 parent
a6519a1
commit aebd140
Showing
55 changed files
with
535 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/HotChocolate/AspNetCore/src/AspNetCore/GlobalStateHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using HotChocolate.Resolvers; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace HotChocolate.AspNetCore; | ||
|
||
internal static class GlobalStateHelpers | ||
{ | ||
public static HttpContext GetHttpContext(IPureResolverContext context) | ||
{ | ||
if (context.ContextData.TryGetValue(nameof(HttpContext), out var value) && | ||
value is HttpContext httpContext) | ||
{ | ||
return httpContext; | ||
} | ||
|
||
throw new MissingStateException("Resolver", nameof(HttpContext), StateKind.Global); | ||
} | ||
|
||
public static HttpRequest GetHttpRequest(IPureResolverContext context) | ||
=> GetHttpContext(context).Request; | ||
|
||
public static HttpResponse GetHttpResponse(IPureResolverContext context) | ||
=> GetHttpContext(context).Response; | ||
} |
98 changes: 0 additions & 98 deletions
98
src/HotChocolate/AspNetCore/src/AspNetCore/HttpContextParameterExpressionBuilder.cs
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...tCore/src/AspNetCore/ParameterExpressionBuilders/HttpContextParameterExpressionBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
using HotChocolate.Internal; | ||
using HotChocolate.Resolvers; | ||
using HotChocolate.Resolvers.Expressions; | ||
using HotChocolate.Resolvers.Expressions.Parameters; | ||
using HotChocolate.Utilities; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace HotChocolate.AspNetCore.ParameterExpressionBuilders; | ||
|
||
internal sealed class HttpContextParameterExpressionBuilder | ||
: LambdaParameterExpressionBuilder<IPureResolverContext, HttpContext> | ||
{ | ||
public HttpContextParameterExpressionBuilder() | ||
: base(ctx => GlobalStateHelpers.GetHttpContext(ctx)) { } | ||
|
||
public override ArgumentKind Kind => ArgumentKind.GlobalState; | ||
|
||
public override bool CanHandle(ParameterInfo parameter) | ||
=> parameter.ParameterType == typeof(HttpContext); | ||
} |
20 changes: 20 additions & 0 deletions
20
...tCore/src/AspNetCore/ParameterExpressionBuilders/HttpRequestParameterExpressionBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Reflection; | ||
using HotChocolate.Internal; | ||
using HotChocolate.Resolvers; | ||
using HotChocolate.Resolvers.Expressions.Parameters; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace HotChocolate.AspNetCore.ParameterExpressionBuilders; | ||
|
||
internal sealed class HttpRequestParameterExpressionBuilder | ||
: LambdaParameterExpressionBuilder<IPureResolverContext, HttpRequest> | ||
{ | ||
public HttpRequestParameterExpressionBuilder() | ||
: base(ctx => GlobalStateHelpers.GetHttpRequest(ctx)) { } | ||
|
||
public override ArgumentKind Kind => ArgumentKind.GlobalState; | ||
|
||
public override bool CanHandle(ParameterInfo parameter) | ||
=> parameter.ParameterType == typeof(HttpRequest); | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
...Core/src/AspNetCore/ParameterExpressionBuilders/HttpResponseParameterExpressionBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Reflection; | ||
using HotChocolate.Internal; | ||
using HotChocolate.Resolvers; | ||
using HotChocolate.Resolvers.Expressions.Parameters; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace HotChocolate.AspNetCore.ParameterExpressionBuilders; | ||
|
||
internal sealed class HttpResponseParameterExpressionBuilder | ||
: LambdaParameterExpressionBuilder<IPureResolverContext, HttpResponse> | ||
{ | ||
public HttpResponseParameterExpressionBuilder() | ||
: base(ctx => GlobalStateHelpers.GetHttpResponse(ctx)) { } | ||
|
||
public override ArgumentKind Kind => ArgumentKind.GlobalState; | ||
|
||
public override bool CanHandle(ParameterInfo parameter) | ||
=> parameter.ParameterType == typeof(HttpResponse); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.