1

Hope you're doing well ?

I'm facing an issue with Apollo Client querying a Strapi API.

I've created the following mutation :

export const POST_MOBILE_USER = gql`
  mutation CreateMobileUser(
    $first_name: String!
    $isOnboarded: Boolean!
    $isSignedUp: Boolean!
    $isUnder25: Boolean!
    $points: Integer!
    $user_id: String!
  ) {
    createUtilisateursMobile(
      input: {
        data: {
          first_name: "$first_name"
          isOnboarded: true
          isSignedUp: $isSignedUp
          isUnder25: $isUnder25
          points: $points
          user_id: $user_id
        }
      }
    ) {
      utilisateursMobile {
        user_id
        first_name
        isOnboarded
        isSignedUp
        isUnder25
        points
      }
    }
  }
`;

And I am using useMutation hook in my component to pass an object in order to post on my database.

Here is the call made in my signup component :

const [signUpUser] = useMutation(POST_MOBILE_USER, {
    onError(error) {
      console.log('ERR', error);
    },
  });

Here is the signUpuser() call made onPress on my confirm button :

const handleValidation = async () => {
    tmpUser.isSignedUp = true;
    tmpUser.points = 0;
    console.log('tmpUser', tmpUser);
    try {
      await signUpUser({
        variables: {
          first_name: tmpUser.first_name,
          isOnboarded: tmpUser.isOnboarded,
          isSignedUp: tmpUser.isSignedUp,
          isUnder25: tmpUser.isUnder25,
          points: tmpUser.points,
          user_id: tmpUser.user_id,
        },
      });
      setUser({...tmpUser});
    } catch (err) {
      console.log('ICI', err);
    }

The issue i'm facing is a 400 Bad request with no further information than :

ERR [Error: Response not successful: Received status code 400]

Does anyonne faced the same issue ? Or can someone help me go through this I've been stucked for the last two days !

Thank you !!

Brian Rid
  • 45
  • 6

0 Answers0