I encountered a mutation that looks like this-
mutation signUp($avatar: Upload!) {
signUp(
avatar: $avatar
input: {
name: "Siam Ahnaf"
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff8c969e929e97919e99cec6c7bf9e9093d19c9092">[email protected]</a>"
password: "12345678" }
) {
message
token
}
}
To execute this, I sent a request from my Next.js application like this-
var formData = new FormData();
formData.append('operations', '{ "query": "mutation($file: Upload!) {signUp(avatar: $file, input: {name: "Siam Ahnaf", email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a79636b676b62646b6c3b33324a736b62656524696567">[email protected]</a>", password: "siam1980"}){message, token}}", "variables": { "file": null } }');
formData.append('map', '{ "0": ["variables.file"] }');
formData.append('0', Image);
await axios({
url: "http://localhost:3001/graphql",
method: "post",
data: formData,
Headers: {
'Accept': 'application/json'
}
})
.then(response => console.log(response))
.catch(error => console.log(error));
However, I am now facing an error stating - Invalid JSON in the ‘operations’ multipart field
I am uncertain of where the issue lies within the 'operations' JSON. Any assistance would be greatly appreciated.
Thank you in advance.