Skip to main content

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;
entities?: Array<Type<any>> | (() => Array<Type<any>>);
compatibility?: string;
}
  • Extends: ModuleMetadata

configuration

A function which can modify the VendureConfig object before the server bootstraps.

shopApiExtensions

The plugin may extend the default Vendure GraphQL shop api by providing extended schema definitions and any required resolvers.

adminApiExtensions

The plugin may extend the default Vendure GraphQL admin api by providing extended schema definitions and any required resolvers.

entities

property
Array<Type<any>> | (() => Array<Type<any>>)

The plugin may define custom TypeORM database entities.

compatibility

property
v2.0.0
string

The plugin should define a valid semver version string to indicate which versions of Vendure core it is compatible with. Attempting to use a plugin with an incompatible version of Vendure will result in an error and the server will be unable to bootstrap.

If a plugin does not define this property, a message will be logged on bootstrap that the plugin is not guaranteed to be compatible with the current version of Vendure.

To effectively disable this check for a plugin, you can use an overly-permissive string such as >0.0.0.

Example

compatibility: '^2.0.0'

APIExtensionDefinition

An object which allows a plugin to extend the Vendure GraphQL API.

Signature
interface APIExtensionDefinition {
schema?: DocumentNode | (() => DocumentNode | undefined);
resolvers?: Array<Type<any>> | (() => Array<Type<any>>);
scalars?: Record<string, GraphQLScalarType> | (() => Record<string, GraphQLScalarType>);
}

schema

property
DocumentNode | (() => DocumentNode | undefined)

Extensions to the schema.

Example

const schema = gql`extend type SearchReindexResponse {
timeTaken: Int!
indexedItemCount: Int!
}`;

resolvers

property
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.

scalars

property
v1.7.0
Record<string, GraphQLScalarType> | (() => Record<string, GraphQLScalarType>)

A map of GraphQL scalar types which should correspond to any custom scalars defined in your schema. Read more about defining custom scalars in the Apollo Server Custom Scalars docs

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>