Skip to main content

IsGraphQlErrorResult

isGraphQlErrorResult

Returns true if the ErrorResultUnion is actually an ErrorResult type. This is useful when dealing with certain internal service method that return an ErrorResultUnion.

Example

import { isGraphQlErrorResult } from '@vendure/core';

// ...

const transitionResult = await this.orderService.transitionToState(ctx, order.id, newState);
if (isGraphQlErrorResult(transitionResult)) {
// The transition failed with an ErrorResult
throw transitionResult;
} else {
// TypeScript will correctly infer the type of `transitionResult` to be `Order`
return transitionResult;
}
Signature
function isGraphQlErrorResult<T extends GraphQLErrorResult | U, U = any>(input: T): input is JustErrorResults<T>

Parameters

input

parameter
T