ApiOptions

ApiOptions

ApiOptions

The ApiOptions define how the Vendure GraphQL APIs are exposed, as well as allowing the API layer to be extended with middleware.

Signature

interface ApiOptions {
  hostname?: string;
  port: number;
  adminApiPath?: string;
  shopApiPath?: string;
  adminApiPlayground?: boolean | any;
  shopApiPlayground?: boolean | any;
  adminApiDebug?: boolean;
  shopApiDebug?: boolean;
  channelTokenKey?: string;
  cors?: boolean | CorsOptions;
  middleware?: Array<{ handler: RequestHandler; route: string }>;
  apolloServerPlugins?: PluginDefinition[];
}

Members

hostname

property
type:
string
default:
''
Set the hostname of the server. If not set, the server will be available on localhost.

port

property
type:
number
default:
3000
Which port the Vendure server should listen on.

adminApiPath

property
type:
string
default:
'admin-api'
The path to the admin GraphQL API.

shopApiPath

property
type:
string
default:
'shop-api'
The path to the admin GraphQL API.

adminApiPlayground

property
type:
boolean | any
default:
false
The playground config to the admin GraphQL API ApolloServer playground.

shopApiPlayground

property
type:
boolean | any
default:
false
The playground config to the shop GraphQL API ApolloServer playground.

adminApiDebug

property
type:
boolean
default:
false
The debug config to the admin GraphQL API ApolloServer playground.

shopApiDebug

property
type:
boolean
default:
false
The debug config to the admin GraphQL API ApolloServer playground.

channelTokenKey

property
type:
string
default:
'vendure-token'
The name of the property which contains the token of the active channel. This property can be included either in the request header or as a query string.

cors

property
type:
boolean | CorsOptions
default:
{ origin: true, credentials: true }
Set the CORS handling for the server. See the express CORS docs.

middleware

property
type:
Array<{ handler: RequestHandler; route: string }>
default:
[]
Custom Express middleware for the server.

apolloServerPlugins

property
type:
PluginDefinition[]
default:
[]

Custom ApolloServerPlugins which allow the extension of the Apollo Server, which is the underlying GraphQL server used by Vendure.

Apollo plugins can be used e.g. to perform custom data transformations on incoming operations or outgoing data.