Graphql Apollo客户端在React组件中出现错误400
突变gql标签: 提交时的突变函数Graphql Apollo客户端在React组件中出现错误400,graphql,next.js,react-apollo,apollo-client,Graphql,Next.js,React Apollo,Apollo Client,突变gql标签: 提交时的突变函数 onSubmitLogin=async(e,appAdminLogin)=>{ const{email,password}=this.state; e、 预防默认值(); 如果(!validator.isEmail(电子邮件)){ console.log(“非电子邮件格式”); 返回; } 如果(密码长度
onSubmitLogin=async(e,appAdminLogin)=>{
const{email,password}=this.state;
e、 预防默认值();
如果(!validator.isEmail(电子邮件)){
console.log(“非电子邮件格式”);
返回;
}
如果(密码长度<8){
返回;
}
阿帕德米洛金({
变量:{
电子邮件,
密码
}
});
};
当onSubmitLogin登录时,我是否收到错误400(错误请求)
我做错了什么?
对不起,我的英语技能xD400状态表示您的查询无效。请在浏览器的开发工具中检查服务器的实际响应——它将包含一个
错误
数组,其原因是查询无效。我已经解决了它,我的变异函数出错了。谢谢
// AppAdminLoinInput is wrong spell don't focus it.
const LOGIN_MUTATION = gql`
mutation AppAdminLoinInput($email: String!, $password: String!) {
appAdminLogin(email: $email, password: $password) {
name
email
token {
accessToken
refreshToken
}
}
}
`;
onSubmitLogin = async (e, appAdminLogin) => {
const { email, password } = this.state;
e.preventDefault();
if (!validator.isEmail(email)) {
console.log("Not email format");
return;
}
if (password.length < 8) {
return;
}
appAdminLogin({
variables: {
email,
password
}
});
};