productReviewRatingsMetadata
Get the active ratings attributes and the values each rating can have.
Signature
declare function productReviewRatingsMetadata(
context: Context,
customQuery?: CustomQuery,
customHeaders?: CustomHeaders
): Promise<ApolloQueryResult<ProductReviewRatingsMetadata>>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | Context | |
customQuery | Optional | CustomQuery | |
customHeaders | Optional | CustomHeaders |
Referenced Types
- Context
- CustomQuery
- CustomHeaders
ApolloQueryResult- ProductReviewRatingsMetadata
Examples
Simple usage:
import { sdk } from '~/sdk.config.ts';
// fetch the active ratings attributes and the values each rating can have
const { data } = await sdk.magento.productReviewRatingsMetadata();
data.productReviewRatingsMetadata.items; // array of review's attributes
data.productReviewRatingsMetadata.items[0].values; // array of possible values of the review's attributesCreating a custom GraphQL query
module.exports = {
integrations: {
magento: {
customQueries: {
'product-review-ratings-metadata-custom-query': ({ variables, metadata }) => ({
variables,
query: `
query productReviewRatingsMetadata {
productReviewRatingsMetadata {
items {
${metadata.fields}
}
}
}
`
}),
},
}
}
};Using a custom GraphQL query to reduce the amount of data returned by the query
import { sdk } from '~/sdk.config.ts';
// reduce the amount of fields returned by the query, when compared to the default query
const customQuery = {
productReviewRatingsMetadata: 'product-review-ratings-metadata-custom-query',
metadata: {
fields: `
name
values {
value
}
`
}
};
const { data } = await sdk.magento.productReviewRatingsMetadata(customQuery);
// data.productReviewRatingsMetadata.items[0] will contain only the fields specified in the custom query.