Back to Content Management API
productPage
Returns a product page by ID in a draft or published state.
Arguments
- Name
id
- Type
- ID!
- Description
The ID of the product page.
- Name
version
- Type
- Version
- Description
The state of the product page you want to retrieve.
- To get the latest content use
CURRENT
. - To get the latest published content use
PUBLISHED
- To get the latest content use
- Name
country
- Type
- CountryCode
- Description
The country context for the query. Used with the
@inContext
directive.
- Name
language
- Type
- LanguageCode
- Description
The language context for the query. Used with the
@inContext
directive.
Returns
- Name
ProductPage.*
- Type
- ProductPage
- Description
Any requested field from the Productpage object.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN'
});
const query = `
query ProductPage($id: ID!, $country: CountryCode, $language: LanguageCode) @inContext(country: $country, language: $language) {
productPage(id: $id) {
title
handle
seo {
title
description
}
}
}
`;
const variables = {
id: 'product-page-id',
country: 'US',
language: 'EN'
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"productPage": {
"title": "Product Title",
"handle": "product-handle",
"seo": {
"title": "Product Title",
"description": "Product Description",
}
}
}
}