Class MutationState<TData>
- Namespace
- DotNetQuery.Core
- Assembly
- DotNetQuery.Core.dll
An immutable snapshot of a mutation's current state. Use the static factory methods to create instances.
public sealed record MutationState<TData> : IEquatable<MutationState<TData>>
Type Parameters
TDataThe type of data returned by the mutation on success.
- Inheritance
-
MutationState<TData>
- Implements
-
IEquatable<MutationState<TData>>
- Inherited Members
Properties
CurrentData
The data returned by the most recent successful execution.
null when the mutation has not yet succeeded.
public TData? CurrentData { get; }
Property Value
- TData
Error
The exception from the most recent failed execution. null when not in a failure state.
public Exception? Error { get; }
Property Value
HasData
true when the mutation has succeeded and CurrentData is available.
public bool HasData { get; }
Property Value
HasError
true when Error is not null.
public bool HasError { get; }
Property Value
IsFailure
public bool IsFailure { get; }
Property Value
IsIdle
public bool IsIdle { get; }
Property Value
IsRunning
public bool IsRunning { get; }
Property Value
IsSuccess
public bool IsSuccess { get; }
Property Value
Status
The current lifecycle status of the mutation.
public MutationStatus Status { get; }
Property Value
Methods
CreateFailure(Exception)
Creates a Failure state with the given error.
public static MutationState<TData> CreateFailure(Exception error)
Parameters
errorExceptionThe exception thrown by the mutation.
Returns
- MutationState<TData>
CreateIdle()
Creates an Idle state.
public static MutationState<TData> CreateIdle()
Returns
- MutationState<TData>
CreateRunning()
Creates a Running state.
public static MutationState<TData> CreateRunning()
Returns
- MutationState<TData>
CreateSuccess(TData)
Creates a Success state with the returned data.
public static MutationState<TData> CreateSuccess(TData data)
Parameters
dataTDataThe data returned by the mutation.
Returns
- MutationState<TData>