Skip to content

Commit

Permalink
Migrated missing extension methods
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Apr 22, 2022
1 parent 2614e5d commit 0aec6b9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
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);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,10 @@
<data name="ThrowHelper_SchemaCoordinate_MemberNameCannotBeSetOnADirectiveCoordinate" xml:space="preserve">
<value>A directive cannot contain a member name.</value>
</data>
<data name="ExecutionResultExtensions_ExpectResponseStream_NotResponseStream" xml:space="preserve">
<value>The specified result is expected to be a IResponseStream.</value>
</data>
<data name="ExecutionResultExtensions_ExpectQueryResult_NotQueryResult" xml:space="preserve">
<value>The specified result is expected to be a IQueryResult.</value>
</data>
</root>

0 comments on commit 0aec6b9

Please sign in to comment.