I am using a graphql query where the user inputs a name in a text field, which is then splitted into firstName and lastName and then passed into a query.
The where query generally works correctly with one variable but in this case, I keep getting an error that value of $where has a wrong structure
This query runs perfectly on my playground: ^
query{
users(where: { firstName:"Myname", AND: {lastName:"Hello"}}){
nodes{
firstName,lastName,id, email, phoneNumber, userRelations{id,userId,type,relatedUserId}
}
}
}
And this is what I am doing in my code:
const handleSubmit = React.useCallback(() => {
let bothNames = name.split(" ");
setFirstName(bothNames[0]);
setLastName(bothNames[1]);
console.log('Submitted');
loadUsers({
variables: {
where: { firstName: firsttName, AND: {lastName:lasttName}},
},
});
setName('');
}, [loadUsers, name, firsttName, lasttName]);
Something like this works:
where: { phoneNumber: phoneNumber },
What am I doing wrong?
ANDlike theseAND: [ {} ]- Glory Raj