FulfillmentHandler
A FulfillmentHandler is used when creating a new Fulfillment. When the addFulfillmentToOrder mutation
is executed, the specified handler will be used and it's createFulfillment method is called. This method
may perform async tasks such as calling a 3rd-party shipping API to register a new shipment and receive
a tracking code. This data can then be returned and will be incorporated into the created Fulfillment.
If the args property is defined, this means that arguments passed to the addFulfillmentToOrder mutation
will be passed through to the createFulfillment method as the last argument.
Example
- Extends:
ConfigurableOperationDef<T>
constructor
(config: FulfillmentHandlerConfig<T>) => FulfillmentHandlerThe configuration object used to instantiate a FulfillmentHandler.
- Extends:
ConfigurableOperationDefOptions<T>
createFulfillment
CreateFulfillmentFn<T>Invoked when the addFulfillmentToOrder mutation is executed with this handler selected.
If an Error is thrown from within this function, no Fulfillment is created and the CreateFulfillmentError
result will be returned.
onFulfillmentTransition
This allows the handler to intercept state transitions of the created Fulfillment. This works much in the
same way as the FulfillmentProcess onTransitionStart method (i.e. returning false or
string will be interpreted as an error and prevent the state transition), except that it is only invoked
on Fulfillments which were created with this particular FulfillmentHandler.
It can be useful e.g. to intercept Fulfillment cancellations and relay that information to a 3rd-party shipping API.
The function called when creating a new Fulfillment