My useLazyQuery and mutation isn't returning any data

My useLazyQuery isn’t working and mutation also. but when a normal query without parameters is working fine. I get a 400 bad request. please help

//my login query
export const LOGIN = gql`
    query login ($email: String, $password: String){
        login(email: $email, password: $password){

//declaring the useLazyQuery
    const [login, {called, loading, error,data}] = useLazyQuery(LOGIN, {variables: {email, password} })


onClick={(e)=>{ }

while the below code works well and returns the token on the playground

query login {
    email: "",
    password: "1234"

Hello! The error returned by useLazyQuery should provide more details into the nature of the bad request (you can also check it in the Network tab of your browser’s developer tools).

One initial thought: Check your schema to see whether the email and password arguments of the login field are of type String or String!

If they’re of type String! (non-nullable), then the types of your two variables also need to be non-nullable:

query login ($email: String!, $password: String!){
1 Like

Hey @StephenBarlow, thank you so much for your help. the issue is resolved with this solution. and thank you very much for referring me to the network tab, I never knew I could get such detailed error messages from there.