-
-
Notifications
You must be signed in to change notification settings - Fork 744
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
1 parent
2614e5d
commit 0aec6b9
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/HotChocolate/Core/src/Abstractions/Execution/ExecutionResultExtensions.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,44 @@ | ||
using System; | ||
using static HotChocolate.Properties.AbstractionResources; | ||
|
||
namespace HotChocolate.Execution; | ||
|
||
/// <summary> | ||
/// Helper methods for <see cref="IExecutionResult"/>. | ||
/// </summary> | ||
public static class ExecutionResultExtensions | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="result"></param> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentException"></exception> | ||
public static IQueryResult ExpectQueryResult(this IExecutionResult result) | ||
{ | ||
if (result is IQueryResult qr) | ||
{ | ||
return qr; | ||
} | ||
|
||
throw new ArgumentException( | ||
ExecutionResultExtensions_ExpectQueryResult_NotQueryResult); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="result"></param> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentException"></exception> | ||
public static IResponseStream ExpectResponseStream(this IExecutionResult result) | ||
{ | ||
if (result is IResponseStream rs) | ||
{ | ||
return rs; | ||
} | ||
|
||
throw new ArgumentException( | ||
ExecutionResultExtensions_ExpectResponseStream_NotResponseStream); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/HotChocolate/Core/src/Abstractions/Properties/AbstractionResources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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