import gql from 'graphql-tag'
import { client } from '@operato/graphql'

export async function queryDataKeySets(): Promise<
  { id: string; name: string; description: string; active: boolean }[]
> {
  const response = await client.query({
    query: gql`
      query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
        responses: dataKeySets(filters: $filters, pagination: $pagination, sortings: $sortings) {
          items {
            id
            name
            description
            active
          }
          total
        }
      }
    `,
    variables: {
      filters: [
        {
          name: 'active',
          operator: 'eq',
          value: true
        }
      ],
      pagination: {},
      sortings: []
    }
  })

  return response.data.responses.items
}
