-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
120 changed files
with
9,912 additions
and
1,597 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
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
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
85 changes: 85 additions & 0 deletions
85
src/HotChocolate/Core/src/Execution/Internal/MiddlewareContextMarshal.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,85 @@ | ||
using System; | ||
using HotChocolate.Execution.Processing; | ||
using HotChocolate.Resolvers; | ||
|
||
namespace HotChocolate.Execution.Internal; | ||
|
||
/// <summary> | ||
/// An unsafe class that provides a set of methods to access the | ||
/// underlying data representations of the middleware context. | ||
/// </summary> | ||
public static class MiddlewareContextMarshal | ||
{ | ||
/// <summary> | ||
/// Gets access to the result data of an object in the GraphQL execution. | ||
/// ResultData is pooled and writing to it can corrupt the result. | ||
/// Multiple threads might be writing into the result object. | ||
/// </summary> | ||
/// <param name="context"> | ||
/// The resolver context. | ||
/// </param> | ||
/// <returns> | ||
/// Returns the result data of the current resolver context. | ||
/// </returns> | ||
public static ObjectResult? GetParentResultUnsafe(IResolverContext context) | ||
{ | ||
if (context is null) | ||
{ | ||
throw new ArgumentNullException(nameof(context)); | ||
} | ||
|
||
return context is MiddlewareContext middlewareContext | ||
? middlewareContext.ParentResult | ||
: null; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the parent result data of the current <paramref name="resultData"/>. | ||
/// </summary> | ||
/// <param name="resultData"> | ||
/// The result data for which to get the parent. | ||
/// </param> | ||
/// <typeparam name="T"> | ||
/// The type of the result data. | ||
/// </typeparam> | ||
/// <returns> | ||
/// Returns the parent result data of the current <paramref name="resultData"/>. | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// Throws if <paramref name="resultData"/> is <c>null</c>. | ||
/// </exception> | ||
public static ResultData? GetParent<T>(T resultData) where T : ResultData | ||
{ | ||
if (resultData == null) | ||
{ | ||
throw new ArgumentNullException(nameof(resultData)); | ||
} | ||
|
||
return resultData.Parent; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the index under which the <paramref name="resultData"/> is stored in the parent result. | ||
/// </summary> | ||
/// <param name="resultData"> | ||
/// The result data for which to get the parent index. | ||
/// </param> | ||
/// <typeparam name="T"> | ||
/// The type of the result data. | ||
/// </typeparam> | ||
/// <returns> | ||
/// Returns the index under which the <paramref name="resultData"/> is stored in the parent result. | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// Throws if <paramref name="resultData"/> is <c>null</c>. | ||
/// </exception> | ||
public static int GetParentIndex<T>(T resultData) where T : ResultData | ||
{ | ||
if (resultData == null) | ||
{ | ||
throw new ArgumentNullException(nameof(resultData)); | ||
} | ||
|
||
return resultData.ParentIndex; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/HotChocolate/Core/src/Execution/Processing/MiddlewareContext.Global.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
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.