import { gql } from '@apollo/client'

export const GET_API_KEYS = gql`
  query GetApiKeys {
    apiKeys {
      id
      name
      keyPrefix
      permissions
      lastUsedAt
      expiresAt
      createdAt
    }
  }
`

export const GET_API_KEY = gql`
  query GetApiKey($id: ID!) {
    apiKey(id: $id) {
      id
      name
      keyPrefix
      permissions
      lastUsedAt
      expiresAt
      createdAt
    }
  }
`

export const CREATE_API_KEY = gql`
  mutation CreateApiKey($input: CreateApiKeyInput!) {
    createApiKey(input: $input) {
      id
      name
      key
      createdAt
    }
  }
`

export const UPDATE_API_KEY = gql`
  mutation UpdateApiKey($id: ID!, $input: UpdateApiKeyInput!) {
    updateApiKey(id: $id, input: $input) {
      id
      name
      keyPrefix
      permissions
      expiresAt
      updatedAt
    }
  }
`

export const REVOKE_API_KEY = gql`
  mutation RevokeApiKey($id: ID!) {
    revokeApiKey(id: $id)
  }
`

