Alokai

getStores

Method fetching the list of stores

In turn, it fetches a stores from commercetools by sending a request to its GraphQL API.

By default, it uses the getProductDefaultQuery GraphQL query

Signature

declare function getStores(
	context: CommercetoolsIntegrationContext,
	params?: GetStoresParams,
	customQuery?: CustomQuery
): Promise<GetStoresResponse>;

Parameters

NameRequiredTypeDescription
contextRequiredCommercetoolsIntegrationContext
paramsOptionalGetStoresParams
customQueryOptionalCustomQuery

Returns

Returns a representation of the GetStoresResponse.

Referenced Types

Examples

Fetching list of stores.

const result = await sdk.commerce.getStores();

Fetching list of stores the way, that the response is cacheable, by passing variables explicitly instead of getting values from cookies.

const result = await sdk.commerce.getStores({
 locale: "en"
});

Fetching paginated list of stores.

const result = await sdk.commerce.getStores({
 limit: 10,
 offset: 1
});

Creating a custom query to modify the response.

export const integrations = {
    ct: {
      // ...
      customQueries: {
       'get-stores-custom-query': ({ variables, metadata }) => ({
         variables,
         query: `
           query stores(
             $where: String
             $sort: [String!]
             $limit: Int
             $offset: Int
           ) {
             stores(
               where: $where
               sort: $sort
               limit: $limit
               offset: $offset
             ) {
               ${metadata?.fields}
             }
           }
         `
       }),
      }
    }
  }
};

Fetching list of stores with custom query.


const result = await sdk.commerce.getStores(\{\}, customQuery);

// result will be modified by the custom query

On this page