Store Context
Use the @storeContext directive to execute a Storefront GraphQL operation in a specific storefront context. This is
useful when you need to control the language, country, or currency for the response, or when you want to resolve the
operation in an authenticated customer’s context.
Supported arguments
language- Language code for the response, for examplefiorencountry- Country code for the storefront context, for exampleFIorSEcurrency- Currency code used in the response, for exampleEURorSEKcustomerAccessToken- Customer access token for authenticated customer context
Example: localized product query
query GetFinnishProducts @storeContext(language: "fi", country: "FI", currency: "EUR") {
catalog {
products {
edges {
node {
id
title
price
}
}
}
}
}Using customerAccessToken
@storeContext also accepts customerAccessToken. Retrieve the token with the customerAccessTokenCreate mutation,
then pass the returned accessToken value into the directive.
mutation CreateCustomerAccessToken {
customerAccessTokenCreate(input: {
email: "customer@example.com"
password: "SecurePassword123"
}) {
customerAccessToken {
accessToken
expiresAt
}
}
}query GetPersonalizedCatalog($customerAccessToken: String!) @storeContext(
language: "fi"
country: "FI"
currency: "EUR"
customerAccessToken: $customerAccessToken
) {
catalog {
products {
edges {
node {
id
title
price
}
}
}
}
}