Skip to main content

ActiveOrderService

ActiveOrderService

This helper class is used to get a reference to the active Order from the current RequestContext.

Signature
class ActiveOrderService {
constructor(sessionService: SessionService, orderService: OrderService, connection: TransactionalConnection, configService: ConfigService)
getOrderFromContext(ctx: RequestContext) => Promise<Order | undefined>;
getOrderFromContext(ctx: RequestContext, createIfNotExists: true) => Promise<Order>;
getOrderFromContext(ctx: RequestContext, createIfNotExists: = false) => Promise<Order | undefined>;
getActiveOrder(ctx: RequestContext, input: { [strategyName: string]: any } | undefined) => Promise<Order | undefined>;
getActiveOrder(ctx: RequestContext, input: { [strategyName: string]: any } | undefined, createIfNotExists: true) => Promise<Order>;
getActiveOrder(ctx: RequestContext, input: { [strategyName: string]: Record<string, any> | undefined } | undefined, createIfNotExists: = false) => Promise<Order | undefined>;
}

constructor

method
(sessionService: SessionService, orderService: OrderService, connection: TransactionalConnection, configService: ConfigService) => ActiveOrderService

getOrderFromContext

method
(ctx: RequestContext) => Promise<Order | undefined>

Gets the active Order object from the current Session. Optionally can create a new Order if no active Order exists.

Intended to be used at the Resolver layer for those resolvers that depend upon an active Order being present.

getOrderFromContext

method
(ctx: RequestContext, createIfNotExists: true) => Promise<Order>

getOrderFromContext

method
(ctx: RequestContext, createIfNotExists: = false) => Promise<Order | undefined>

getActiveOrder

method
v1.9.0
(ctx: RequestContext, input: { [strategyName: string]: any } | undefined) => Promise<Order | undefined>

Retrieves the active Order based on the configured ActiveOrderStrategy.

getActiveOrder

method
(ctx: RequestContext, input: { [strategyName: string]: any } | undefined, createIfNotExists: true) => Promise<Order>

getActiveOrder

method
(ctx: RequestContext, input: { [strategyName: string]: Record<string, any> | undefined } | undefined, createIfNotExists: = false) => Promise<Order | undefined>