import { graphql } from '../generated'

export const LOGIN_MUTATION = graphql(`
  mutation Login($payload: LoginPayload!) {
    login(payload: $payload) {
      accessToken
      refreshToken
      token
      user {
        id
        lastName
        firstName
        middleName
        email
        login
        role
        active
        createdAt
        updatedAt
      }
    }
  }
`)

export const REFRESH_SESSION_MUTATION = graphql(`
  mutation RefreshSession($payload: RefreshSessionPayload!) {
    refreshSession(payload: $payload) {
      accessToken
      refreshToken
      token
      user {
        id
        lastName
        firstName
        middleName
        email
        login
        role
        active
        createdAt
        updatedAt
      }
    }
  }
`)

export const CURRENT_USER_QUERY = graphql(`
  query CurrentUser {
    currentUser {
      id
      lastName
      firstName
      middleName
      email
      login
      role
      active
      createdAt
      updatedAt
    }
  }
`)

export const LOGOUT_MUTATION = graphql(`
  mutation Logout {
    logout
  }
`)
