An EntityDuplicator is used to define the logic for duplicating entities when the duplicateEntity mutation is called.
This allows you to add support for duplication of both core and custom entities.
For entities which implement ChannelAware, the EntityDuplicatorService checks that the source
entity belongs to the active Channel before it calls duplicate(). The check keys on the entity class
name: it runs only when the entityName of the input equals the name of a registered entity class. A
duplicator registered under another name (for example 'Thing' for a class ThingEntity) gets no
check and no warning, and must scope its own lookup.
Example
The duplicator then gets passed to your VendureConfig object:
ConfigurableOperationDef<T>(input: { ctx: RequestContext; entityName: string; id: ID; args: ConfigArg[]; }) => Promise<VendureEntity>A function which performs the duplication of an entity.
Configuration for creating a new EntityDuplicator.
ConfigurableOperationDefOptions<T>Array<Permission | string> | Permission | stringThe permissions required in order to execute this duplicator. If an array is passed, then the administrator must have at least one of the permissions in the array.
string[]The entities for which this duplicator is able to duplicate.
DuplicateEntityFn<T>The function which performs the duplication.
Example