A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I noticed while uploading images via the fileCreate mutation that some images would have a UUID appended no matter what value I would specify for the duplicateResolutionMode.
mutation:
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
...file
}
userErrors {
field
message
}
}
}
variables:
{
"files": [
{
"alt": "Alt Text",
"contentType": "IMAGE",
"duplicateResolutionMode": "REPLACE",
"filename": "some_image_thumb.jpg",
"originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
}
]
}
Solved! Go to the solution
This is an accepted solution.
The key was the "_thumb.jpg" at the end of the filename. If you change the filename by removing the "_thumb" you can work around the bug in the API and your REPLACE or RAISE_ERROR duplicateResolutionMode will be honored.
There is a similar bug for files ending in underscore followed by digits. For example: "_1000.jpg" and "_1000x600.jpg" as well. Removing this these trailing patterns from the filename field allows you work around this issue. The originalSource field can continue to have the "_thumb" or "_1000" patterns included.
So this will work:
{
"files": [
{
"alt": "Alt Text",
"contentType": "IMAGE",
"duplicateResolutionMode": "REPLACE",
"filename": "some_image.jpg",
"originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
}
]
}
The resulting upload will be at
https://cdn.shopify.com/s/files/1/{ACCO/UNTN/UMBER}/files/some_image.jpg?v={timestamp}
This is an accepted solution.
The key was the "_thumb.jpg" at the end of the filename. If you change the filename by removing the "_thumb" you can work around the bug in the API and your REPLACE or RAISE_ERROR duplicateResolutionMode will be honored.
There is a similar bug for files ending in underscore followed by digits. For example: "_1000.jpg" and "_1000x600.jpg" as well. Removing this these trailing patterns from the filename field allows you work around this issue. The originalSource field can continue to have the "_thumb" or "_1000" patterns included.
So this will work:
{
"files": [
{
"alt": "Alt Text",
"contentType": "IMAGE",
"duplicateResolutionMode": "REPLACE",
"filename": "some_image.jpg",
"originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
}
]
}
The resulting upload will be at
https://cdn.shopify.com/s/files/1/{ACCO/UNTN/UMBER}/files/some_image.jpg?v={timestamp}
I'm glad you figured this out and thanks for coming back to post the answer!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hello, thx for your answer
I think it's the same for "-1000.jpg"... How do you know what's working and what's not ?
It's been a bit since I worked on this, but I think I logged out an error in my program when the file names before and after did not match
Ok so you tried and tried and when it didn't work you logged it and found a pattern.
Thx again for your answer to yourself 🙂