import { gql } from '@apollo/client'

const USERS = gql`
  query USERS {
    users {
      id
      email
      name
      permissions
      interests
    }
  }
`

const USER_SIGNUP = gql`
  mutation USER_SIGNUP($email: String!, $password: String!, $name: String!) {
    signup(email: $email, password: $password, name: $name) {
      id
      email
      name
    }
  }
`

const USER_LOGIN = gql`
  mutation USER_LOGIN($email: String!, $password: String!) {
    login(email: $email, password: $password) {
      id
      email
      name
    }
  }
`

const USER_LOGOUT = gql`
  mutation USER_LOGOUT {
    logout
  }
`

const CURRENT_USER = gql`
  query CURRENT_USER {
    me {
      id
      email
      name
      permissions
      interests
    }
  }
`

const USER_REQUEST_PASSWORD = gql`
  mutation USER_REQUEST_PASSWORD($email: String!) {
    requestReset(email: $email)
  }
`

const USER_RESET_PASSWORD = gql`
  mutation USER_RESET_PASSWORD($token: String!, $password: String!) {
    resetPassword(token: $token, password: $password) {
      id
      name
    }
  }
`

export {
  USERS,
  USER_SIGNUP,
  USER_LOGIN,
  USER_LOGOUT,
  CURRENT_USER,
  USER_REQUEST_PASSWORD,
  USER_RESET_PASSWORD
}
