import { gql } from '@apollo/client';

export const PRODUCT_REVIEWS = gql`
    query fetchReviews($productId: ID!, $first: Int, $after: String, $orderByField: ReviewOrderField!, $orderByDirection: ReviewOrderDirection!, $reviewFilter: ReviewFilter) {
        reviews(productId: $productId, first: $first, after: $after, orderBy: { field: $orderByField, direction: $orderByDirection }, filter: $reviewFilter) {
            totalCount
            pageInfo {
                hasNextPage,
                endCursor
            }
            nodes {
                id
                providerReviewId
                language
                rating
                title
                tags {
                    type
                    label
                    description
                }
                author {
                    name
                    validatedReviewer,
                    avatarUrl
                    title
                    company {
                        name
                        type
                    }
                }
                sections {
                    title
                    content
                }
                createdOn
            }
        }
}
`;

export const PRODUCT_REVIEWS_STATS = gql`
    query fetchStats($productId: ID!) {
        reviewStats(productId: $productId) {
            productId,
            reviewCount,
            averageRating,
            ratingBreakdown {
                rating,
                count
            }
        }
    }
`;
