🚨 Announcing Vendure v2 Beta

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>>);
}

Extends

  • ModuleMetadata

Members

configuration

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

shopApiExtensions

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

adminApiExtensions

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

entities

property
type:
Array<Type<any>> | (() => 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 | undefined);
  resolvers?: Array<Type<any>> | (() => Array<Type<any>>);
  scalars?: Record<string, GraphQLScalarType> | (() => Record<string, GraphQLScalarType>);
}

Members

schema

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

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.

scalars

property
v1.7.0
type:
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>