Customizing Models

Customizing Models with custom fields

Custom fields allow you to add your own custom data properties to many of the Vendure entities. The entities which may be have custom fields defined are listed in the CustomFields documentation

They are specified in the VendureConfig:

const config = {
    // ...
    dbConnectionOptions: {
        // ...
        synchronize: true,  
    customFields: {
        Product: [
            { name: 'infoUrl', type: 'string' },
            { name: 'downloadable', type: 'boolean' },
            { name: 'shortName', type: 'localeString' },
        User: [
            { name: 'socialLoginToken', type: 'string' },

With the example config above, the following will occur:

  1. The database schema will be altered and a column will be added for each custom field. Note: this step requires the TypeORM synchronize option to be set to true as above.
  2. The GraphQL APIs will be modified on bootstrap to add the custom fields to the Product and User types respectively.
  3. If you are using the admin-ui-plugin, the Admin UI detail pages will now contain form inputs to allow the custom field data to be added or edited.