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

export const SINGLE_BLOG_QUERY = gql`
  query SinglePost($slug: ID!) {
    post(id: $slug, idType: SLUG) {
      id
      title
      content
      blogFaqSection {
        easyAccordionId
      }
      excerpt
      date
      slug

      seo {
        title
        metaDesc
        canonical
        opengraphTitle
        opengraphDescription
        opengraphImage {
          sourceUrl
        }
      }

      rmpAvgRating
      rmpVoteCount

      author {
        node {
          name
          avatar {
            url
          }
        }
      }

      categories {
        nodes {
          name
          slug
        }
      }

      featuredImage {
        node {
          sourceUrl
          altText
        }
      }
    }

    allPosts: posts(
      first: 100
      where: { orderby: { field: DATE, order: DESC } }
    ) {
      nodes {
        id
        title
        slug
        date
        excerpt
        featuredImage {
          node {
            sourceUrl
            altText
          }
        }
      }
    }

    relatedPosts: posts(first: 3) {
      nodes {
        id
        title
        slug
        excerpt
        date
        featuredImage {
          node {
            sourceUrl
          }
        }
      }
    }
  }
`;
