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;
shopListQueryLimit?: number;
adminListQueryLimit?: number;
adminApiValidationRules?: Array<(context: ValidationContext) => any>;
shopApiValidationRules?: Array<(context: ValidationContext) => any>;
channelTokenKey?: string;
cors?: boolean | CorsOptions;
middleware?: Middleware[];
apolloServerPlugins?: PluginDefinition[];
introspection?: boolean;
}
Members
hostname
string
''
port
number
3000
adminApiPath
string
'admin-api'
shopApiPath
string
'shop-api'
adminApiPlayground
boolean | any
false
shopApiPlayground
boolean | any
false
adminApiDebug
boolean
false
shopApiDebug
boolean
false
shopListQueryLimit
number
100
PaginatedList
response. In other words,
this is the upper limit of the take
input option.
adminListQueryLimit
number
1000
PaginatedList
response. In other words,
this is the upper limit of the take
input option.
adminApiValidationRules
Array<(context: ValidationContext) => any>
[]
shopApiValidationRules
Array<(context: ValidationContext) => any>
[]
channelTokenKey
string
'vendure-token'
cors
boolean | CorsOptions
{ origin: true, credentials: true }
middleware
apolloServerPlugins
PluginDefinition[]
[]
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.
introspection
boolean
true
Controls whether introspection of the GraphQL APIs is enabled. For production, it is recommended to disable introspection, since exposing your entire schema can allow an attacker to trivially learn all operations and much more easily find any potentially exploitable queries.
Note: when introspection is disabled, tooling which relies on it for things like autocompletion will not work.
Example
{
introspection: process.env.NODE_ENV !== 'production'
}