I am trying to pass variable to mutation through apollo's javascript client, however, it always returns 400 error: [Error: Response not successful: Received status code 400] which indicates there's something wrong with my query
below is my query:
const SET_ADDRESS_LASTUSED = gql`
mutation UpdateAddress($phone: String!, $name: String!) {
updateAddress(input: {
where: {
phone: $phone
},
data: {
name: $name
}
}) {
address {
name
phone
}
}
}
`;
I am calling the mutation like this:
const [updateLastUsed, updateLastUsedResult] = useMutation(SET_ADDRESS_LASTUSED);
// sometime later,
updateLastUsed({
variables: {
phone: "+12345678910",
name: "WhyICanNotChangeMyName?",
},
});
is there something wrong that I didn't notice? I'd be able to successfully mutate if I hardcode the variable like this, but of course, I can't do it this way
const SET_ADDRESS_LASTUSED = gql`
mutation {
updateAddress(input: {
where: {
phone: "+12345678910"
},
data: {
name: "ICanChangeMyName!"
}
}) {
address {
name
phone
}
}
}
`;
Please help. I've been debugging pointlessly for hours... I can always pass a variable to query using a similar way :(
Btw, I am using Strapi Server
Thanks in advance!
Reference: https://www.apollographql.com/docs/react/api/react/hooks/ https://strapi.io/documentation/developer-docs/latest/plugins/graphql.html#graphql
inputin js and pass as variableinputparam?($input: JSON!)doesn't seem to work.. same 400 error ?updateAddressInputlike stated in the SDL hahaha