import { gql } from '@apollo/client'

// Query for getting all pillars
export const GET_PILLARS = gql`
  query GetPillars {
    pillars {
      id
      code
      name
      description
      controls {
        id
        code
        name
        description
      }
    }
  }
`

// Query for getting a specific pillar
export const GET_PILLAR = gql`
  query GetPillar($code: PillarCode!) {
    pillar(code: $code) {
      id
      code
      name
      description
      controls {
        id
        code
        name
        description
        findings {
          id
          resource {
            id
            name
          }
          status
          severity
          title
          description
          recommendation
        }
      }
    }
  }
`

// Query for getting findings
export const GET_FINDINGS = gql`
  query GetFindings($filter: FindingFilter) {
    findings(filter: $filter) {
      id
      control {
        id
        code
        name
        pillar {
          code
          name
        }
      }
      resource {
        id
        name
        type
      }
      status
      severity
      title
      description
      recommendation
      createdAt
      updatedAt
    }
  }
`

// Query for getting risks
export const GET_RISKS = gql`
  query GetRisks($resourceId: ID) {
    risks(resourceId: $resourceId) {
      id
      resource {
        id
        name
        type
      }
      pillar {
        code
        name
      }
      severity
      title
      description
      mitigation
      createdAt
      updatedAt
    }
  }
`

