Skip to main content

ConfigurableOperationDef

A ConfigurableOperationDef is a special type of object used extensively by Vendure to define code blocks which have arguments which are configurable at run-time by the administrator.

This is the mechanism used by:

Any class which extends ConfigurableOperationDef works in the same way: it takes a config object as the constructor argument. That config object extends the ConfigurableOperationDefOptions interface and typically adds some kind of business logic function to it.

For example, in the case of ShippingEligibilityChecker, it adds the check() function to the config object which defines the logic for checking whether an Order is eligible for a particular ShippingMethod.

The args property

The key feature of the ConfigurableOperationDef is the args property. This is where we define those arguments that are exposed via the Admin UI as data input components. This allows their values to be set at run-time by the Administrator. Those values can then be accessed in the business logic of the operation.

The data type of the args can be one of ConfigArgType, and the configuration is further explained in the docs of ConfigArgs.

Dependency Injection

If your business logic relies on injectable providers, such as the TransactionalConnection object, or any of the internal Vendure services or those defined in a plugin, you can inject them by using the config object's init() method, which exposes the Injector.

Here's an example of a ShippingCalculator that injects a service which has been defined in a plugin:

Example

Ts
Signature

code

propertystring

args

propertyT

description

constructor

method(options: ConfigurableOperationDefOptions<T>) => ConfigurableOperationDef

init

method(injector: Injector) =>

destroy

method() =>

toGraphQlType

method(ctx: RequestContext) => ConfigurableOperationDefinition

Convert a ConfigurableOperationDef into a ConfigurableOperationDefinition object, typically so that it can be sent via the API.

argsArrayToHash

method(args: ConfigArg[]) => ConfigArgValues<T>

Coverts an array of ConfigArgs into a hash object:

from: [{ name: 'foo', type: 'string', value: 'bar'}]

to: { foo: 'bar' }

Was this chapter helpful?
Report Issue
Edited Feb 10, 2026ยทEdit this page