import { useQuery, useMutation, useLazyQuery } from '@apollo/react-hooks';
import { gql } from 'apollo-boost';


const GQL = () => {
  const query = gql`
  query Login($login: String!, $password: String!) {
      login(login: $login, password: $password)  
  }
`;

const foo = gql`
mutation CreateUser($login: String!, $password: String!) {
  createUser(login: $login, password: $password) {
    _id
    login
  }
}
`
// refetch - метод для повторного запроса
const [mutateFunction, { data, loading, error }]  = useMutation(foo);
// const [login, { data }] = useLazyQuery(query);
const go = () => {
  mutateFunction({ variables: { login: "test1@test.com", password: 'qwerty' } })
}

const lgn = () => {
  // login({ variables: { login: "test@test.com", password: 'qwerty' } })
}

console.log('data', data)
  return (
    <div>
      Hello

      <button onClick={lgn}>lgn</button>
      <button onClick={go}>GO</button>
    </div>
  )
}

export default GQL;
