Skip to main content

HistoryService

Contains methods relating to HistoryEntry entities. Histories are timelines of actions related to a particular Customer or Order, recording significant events such as creation, state changes, notes, etc.

Custom History Entry Types

Since Vendure v1.9.0, it is possible to define custom HistoryEntry types.

Let's take an example where we have some Customers who are businesses. We want to verify their tax ID in order to allow them wholesale rates. As part of this verification, we'd like to add an entry into the Customer's history with data about the tax ID verification.

First of all we'd extend the GraphQL HistoryEntryType enum for our new type as part of a plugin

Example

Ts

Next we need to create a TypeScript type definition file where we extend the CustomerHistoryEntryData interface. This is done via TypeScript's declaration merging and ambient modules features.

Example

Ts

Note: it works exactly the same way if we wanted to add a custom type for Order history, except in that case we'd extend the OrderHistoryEntryData interface instead.

Now that we have our types set up, we can use the HistoryService to add a new HistoryEntry in a type-safe manner:

Example

Ts
Info

It is also possible to define a UI component to display custom history entry types. See the Custom History Timeline Components guide.

Signature

constructor

method(connection: TransactionalConnection, administratorService: AdministratorService, listQueryBuilder: ListQueryBuilder, eventBus: EventBus) => HistoryService

getHistoryForOrder

method(ctx: RequestContext, orderId: ID, publicOnly: boolean, options?: HistoryEntryListOptions) => Promise<PaginatedList<OrderHistoryEntry>>

createHistoryEntryForOrder

method(args: CreateOrderHistoryEntryArgs<T>, isPublic: = true) => Promise<OrderHistoryEntry>

getHistoryForCustomer

method(ctx: RequestContext, customerId: ID, publicOnly: boolean, options?: HistoryEntryListOptions) => Promise<PaginatedList<CustomerHistoryEntry>>

createHistoryEntryForCustomer

method(args: CreateCustomerHistoryEntryArgs<T>, isPublic: = false) => Promise<CustomerHistoryEntry>

updateOrderHistoryEntry

method(ctx: RequestContext, args: UpdateOrderHistoryEntryArgs<T>) =>

deleteOrderHistoryEntry

method(ctx: RequestContext, id: ID) => Promise<void>

updateCustomerHistoryEntry

method(ctx: RequestContext, args: UpdateCustomerHistoryEntryArgs<T>) =>

deleteCustomerHistoryEntry

method(ctx: RequestContext, id: ID) => Promise<void>
Was this chapter helpful?
Report Issue
Edited Feb 25, 2026ยทEdit this page