🚨 Announcing Vendure v2 Beta

VendurePlugin

VendurePlugin

The VendurePlugin decorator is a means of configuring and/or extending the functionality of the Vendure server. A Vendure plugin is a Nestjs Module, with optional additional metadata defining things like extensions to the GraphQL API, custom configuration or new database entities.

As well as configuring the app, a plugin may also extend the GraphQL schema by extending existing types or adding entirely new types. Database entities and resolvers can also be defined to handle the extended GraphQL types.

Example

import { Controller, Get } from '@nestjs/common';
import { Ctx, PluginCommonModule, ProductService, RequestContext, VendurePlugin } from '@vendure/core';

@Controller('products')
export class ProductsController {
    constructor(private productService: ProductService) {}

    @Get()
    findAll(@Ctx() ctx: RequestContext) {
        return this.productService.findAll(ctx);
    }
}


//A simple plugin which adds a REST endpoint for querying products.
@VendurePlugin({
    imports: [PluginCommonModule],
    controllers: [ProductsController],
})
export class RestPlugin {}

Signature

function VendurePlugin(pluginMetadata: VendurePluginMetadata): ClassDecorator

Parameters

pluginMetadata

parameter