Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for error result objects when using mutation conventions. #5415

Merged
merged 12 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/HotChocolate/Core/src/Abstractions/AggregateError.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using HotChocolate.Properties;
using System.Threading.Tasks;
using static HotChocolate.Properties.AbstractionResources;

namespace HotChocolate;

Expand All @@ -17,7 +19,7 @@ public class AggregateError : Error
/// The errors.
/// </param>
public AggregateError(IEnumerable<IError> errors)
: base(AbstractionResources.AggregateError_Message)
: base(AggregateError_Message)
{
if (errors is null)
{
Expand All @@ -34,7 +36,7 @@ public AggregateError(IEnumerable<IError> errors)
/// The errors.
/// </param>
public AggregateError(params IError[] errors)
: base(AbstractionResources.AggregateError_Message)
: base(AggregateError_Message)
{
Errors = errors ?? throw new ArgumentNullException(nameof(errors));
}
Expand Down
17 changes: 17 additions & 0 deletions src/HotChocolate/Core/src/Abstractions/IMutationResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace HotChocolate;

/// <summary>
/// This interface allows middleware to access the mutation result value in an generic way.
/// </summary>
public interface IMutationResult
{
/// <summary>
/// Gets the mutation result value.
/// </summary>
object Value { get; }

/// <summary>
/// Defines if the mutation was successful and if the result represents a success result.
/// </summary>
bool IsSuccess { get; }
}