Hello,
When I try to set a file_reference
metafield to a value like gid://shopify/ExternalVideo/28048706568273
I get the following error: Value must be a file reference string
but elsewhere in the API external videos are treated like files and they implement the File
interface.
You can reproduce the error by choosing a file to reference in the admin and selecting an external video:
The following GraphQL query also returns the same error:
mutation {
metafieldsSet(metafields: [
{
key: "file_reference",
namespace: "my_fields",
ownerId: "gid://shopify/Product/7744832176209",
type: "file_reference",
value: "gid://shopify/ExternalVideo/28048706568273"
},
]) {
metafields {
key
namespace
value
createdAt
updatedAt
}
userErrors {
field
message
code
}
}
}
One partial workaround when using the GraphQL API is to refer to the external video as a GenericFile
instead. For example passing gid://shopify/GenericFile/28048706568273
instead of gid://shopify/ExternalVideo/28048706568273
. In my tests this appears to work on the storefront with the external_video
media tag.
This isn’t ideal though because it breaks the display in the Shopify admin. You can’t tell what file is connected and users can think that it’s broken:
Does anyone have any other ideas how make the file_reference metafields work better with external videos?
Thanks,
Daniel