简体   繁体   中英

angular Apollo Bad Request

hello dear developers actually i have a problem i'm using Appollo in my Ionic/Angular project and i have this simple mutation in my code

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
      },
    })
  }

when i execute this query in the backend(django) graphical page its working but in the angular project returns bad request 400 what should i do ?

i got it and problem was from types this code is worked

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)
      },
    })
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM