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
Members
configuration
PluginConfigurationFn
shopApiExtensions
APIExtensionDefinition
adminApiExtensions
APIExtensionDefinition
entities
Array<Type<any>> | (() => Array<Type<any>>)
compatibility
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>);
}
Members
schema
DocumentNode | (() => DocumentNode | undefined)
Extensions to the schema.
Example
const schema = gql`extend type SearchReindexResponse {
timeTaken: Int!
indexedItemCount: Int!
}`;
resolvers
Array<Type<any>> | (() => Array<Type<any>>)
@Resolver()
decorator etc.
scalars
Record<string, GraphQLScalarType> | (() => Record<string, GraphQLScalarType>)
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>