微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

角阿波罗错误请求

如何解决角阿波罗错误请求

你好亲爱的开发者实际上我有一个问题 我在我的 Ionic/Angular 项目中使用 Appollo,我有这个简单的 我的代码中的突变

createuser(email,phone_num,password){    
    return this.apollo
    .mutate<any>({
      mutation: gql`
      mutation create_user($email:String!,$phone_num:String!,$password:String!) {
        create_user(input:{email:$email,phone_num:$phone_num,password:$password}){
          user {
            id
            first_name
            last_name
            phone_num
            email
            biography
            gender
            profile_picture
            created_at
            is_active
          }
    message
    ok
    }
} 
      `,variables:{
        email:email,phone_num:phone_num,password:password
      },})
  }

当我在后端(django)图形页面中执行此查询时,它的工作原理 但在角度项目中返回错误的请求 400 我该怎么办?

解决方法

我明白了,问题出在此代码有效的类型

CreateUser(email,phone_num,password){    
    return this.apollo
    .mutate<any>({
      mutation: gql`
      mutation create_user($email:String!,$phone_num:String!,$password:String!) {
        create_user(input:{email:$email,phone_num:$phone_num,password:$password}){
          user {
            id
            first_name
            last_name
            phone_num
            email
            biography
            gender
            profile_picture
            created_at
            is_active
          }
    message
    ok
    }
} 
      `,variables:{
        email:String(email),phone_num:String(phone_num),password:String(password)
      },})
  }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。