FastImporterService
FastImporterService
A service to import entities into the database. This replaces the regular create
methods of the service layer with faster
versions which skip much of the defensive checks and other DB calls which are not needed when running an import. It also
does not publish any events, so e.g. will not trigger search index jobs.
In testing, the use of the FastImporterService approximately doubled the speed of bulk imports.
Signature
class FastImporterService {
async initialize(channel?: Channel) => ;
async createProduct(input: CreateProductInput) => Promise<ID>;
async createProductOptionGroup(input: CreateProductOptionGroupInput) => Promise<ID>;
async createProductOption(input: CreateProductOptionInput) => Promise<ID>;
async addOptionGroupToProduct(productId: ID, optionGroupId: ID) => ;
async createProductVariant(input: CreateProductVariantInput) => Promise<ID>;
}
Members
initialize
method
type:
(channel?: Channel) =>
This should be called prior to any of the import methods, as it establishes the default Channel as well as the context in which the new entities will be created.
Passing a channel
argument means that Products and ProductVariants will be assigned
to that Channel.
createProduct
method
type:
(input: CreateProductInput) => Promise<ID>
createProductOptionGroup
method
type:
(input: CreateProductOptionGroupInput) => Promise<ID>
createProductOption
method
type:
(input: CreateProductOptionInput) => Promise<ID>
addOptionGroupToProduct
createProductVariant
method
type:
(input: CreateProductVariantInput) => Promise<ID>