A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello guys,
I'm tryng to upload a video to a metafield.
Here's the metafield specifications:
"metafield": { "id": "gid://shopify/Metafield/30669385302191", "namespace": "custom", "key": "video_pdp", "value": "gid://shopify/Video/31521214628015", "type": "file_reference" }
Here there is the video because i selected one randomly from the shopify backoffice.
What I'm tryng to do now is to generate a staged url with the mutation stagedUploadsCreate:
mutation stagedUploadsCreate(\$input: [StagedUploadInput!]!) {
stagedUploadsCreate(input: \$input) {
stagedTargets {
url
resourceUrl
parameters {
name
value
}
}
}
}
Than i upload the file to the staged URL with the multipart request.
Finally, I try to get the file id searching the files with the name of my video:
query getFiles(\$query: String!) {
files(first: 1, query: \$query) {
edges {
node {
id
createdAt
fileStatus
}
}
}
}
where query === name.
This doesnt'work and I can't retrive the file ID i need in order to upload the video on the metafield.
Any help will be really appreciated, thank you!!
Hi @LucaRaveri
You should be missing a step: https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/bulkoperationrunmutation
The full process is as follows:
Bulk import data with the GraphQL Admin API (shopify.dev)