When trying to upload a file via the files API, I get an error:
Error uploading file: Variable $input of type [StagedUploadInput!]! was provided invalid value
I am using the Remix Template from the Shopify cli (the recommended one).
I have checked the docs thoroughly, and it seems like there might have been some undocumented change or something.
I see no error with the input variable. I am able to make other GraphQL requests just fine; I only get an error with this particular mutation type (stagedUploadsCreate , which has the StagedUploadInput! type argument).
Here is the code:
const mutation = `
mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {
stagedUploadsCreate(input: $input) {
stagedTargets {
parameters {
name
value
}
resourceUrl
url
}
}
}
`;
const variables = {
input: [
{
filename: "3_soft.jpg",
mimeType: "image/jpeg",
resource: "IMAGE",
httpMethod: "POST",
},
],
};
console.log(variables);
const response = await admin.graphql(mutation, variables);
The variables log correctly logs right before the error:
{
input: [
{
filename: '3_soft.jpg',
mimeType: 'image/jpeg',
resource: 'FILE',
httpMethod: 'POST'
}
]
}
How can I successfully complete the stagedUploadsCreate mutation?