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)
  async getOrderFromContext(ctx: RequestContext) => Promise<Order | undefined>;
  async getOrderFromContext(ctx: RequestContext, createIfNotExists: true) => Promise<Order>;
  async getOrderFromContext(ctx: RequestContext, createIfNotExists:  = false) => Promise<Order | undefined>;
}

Members

constructor

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

getOrderFromContext

async method
type:
(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

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

getOrderFromContext

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