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
                reviewUrl
                reviewLastModified
                syndicationUrl
                syndication {
                    externalProvider
                }
                reviewTags {
                    type
                    label
                    description
                }
                reviewAuthor {
                    name
                    validatedReviewer,
                    avatarUrl
                    title
                    company {
                        name
                        type
                    }
                }
                sections {
                    title
                    content
                }
            }
        }
}
`;

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