VendurePluginMetadata
VendurePluginMetadata
Defines the metadata of a Vendure plugin. This interface is an superset of the Nestjs ModuleMetadata
(which allows the definition of imports
, exports
, providers
and controllers
), which means
that any Nestjs Module is a valid Vendure plugin. In addition, the VendurePluginMetadata allows the definition of
extra properties specific to Vendure.
Signature
interface VendurePluginMetadata extends ModuleMetadata {
configuration?: PluginConfigurationFn;
shopApiExtensions?: APIExtensionDefinition;
adminApiExtensions?: APIExtensionDefinition;
workers?: Array<Type<any>>;
entities?: Array<Type<any>>;
}
Extends
- ModuleMetadata
Members
configuration
property
type:
PluginConfigurationFn
A function which can modify the VendureConfig object before the server bootstraps.
shopApiExtensions
property
type:
APIExtensionDefinition
The plugin may extend the default Vendure GraphQL shop api by providing extended
schema definitions and any required resolvers.
adminApiExtensions
property
type:
APIExtensionDefinition
The plugin may extend the default Vendure GraphQL admin api by providing extended
schema definitions and any required resolvers.
workers
property
type:
Array<Type<any>>
The plugin may define Nestjs microservice controllers
which are run in the Worker context.
entities
property
type:
Array<Type<any>>
The plugin may define custom TypeORM database entities.
APIExtensionDefinition
An object which allows a plugin to extend the Vendure GraphQL API.
Signature
interface APIExtensionDefinition {
schema?: DocumentNode | (() => DocumentNode);
resolvers: Array<Type<any>> | (() => Array<Type<any>>);
}
Members
schema
property
type:
DocumentNode | (() => DocumentNode)
Extensions to the schema.
Example
const schema = gql`extend type SearchReindexResponse {
timeTaken: Int!
indexedItemCount: Int!
}`;
resolvers
property
type:
Array<Type<any>> | (() => Array<Type<any>>)
An array of resolvers for the schema extensions. Should be defined as Nestjs GraphQL resolver
classes, i.e. using the Nest
@Resolver()
decorator etc.
PluginConfigurationFn
This method is called before the app bootstraps and should be used to perform any needed modifications to the VendureConfig.
Signature
type PluginConfigurationFn = (
config: RuntimeVendureConfig,
) => RuntimeVendureConfig | Promise<RuntimeVendureConfig>