Alokai
You are reading the documentation for SDK v2, which is no longer the latest version. Switch to current

SetupContext

Contains current request and response object, integration configuration and helper methods. Currently it uses Middleware's IntegrationContext type utility instead of creating its own context.

export interface SetupContext {
	client: ApolloClient<InMemoryCache>;
	config: Config<InMemoryCache>;
	customQueries?: any;
	extendQuery<Type extends Record<string, ContextQuery>, Key extends keyof Type>(customQuery: CustomQuery, queries: Type): Record<Key, ContextQuery>;
	extensions: ApiClientExtension[];
	req: Request;
	res: Response;
}

Properties

NameRequiredTypeDescription
clientRequiredApolloClient<InMemoryCache>Apollo GraphQL client used to send requests to commercetools platform
configRequiredConfig<InMemoryCache>Integration configuration
customQueriesOptionalanyCustom queries registered in middleware.config.js
extensionsRequiredApiClientExtension[]Array of registered integration extensions
reqRequiredRequestRequest object
resRequiredResponseResponse object

extendQuery

Helper function for handling default and custom queries

Signature

extendQuery<Type extends Record<string,
	ContextQuery>,
	Key extends keyof Type>(
	customQuery: CustomQuery,
	queries: Type
): Record<Key,
	ContextQuery>;

Parameters

NameRequiredTypeDescription
customQueryRequiredCustomQuerycustom query to be used instead of the default query
queriesRequiredTypedefault queries and variables

Returns

Resolved queries

Referenced Types

Referenced Types

  • ApolloClient
  • InMemoryCache
  • Config
  • ApiClientExtension
  • e.Request
  • e.Response

On this page