Hi! community,
I want to get video in metafield for first view.
But, API returns empty Metafield.reference, and component doesn’t work.
See an example code based on demo-store.
const HOMEPAGE_CONTENT_QUERY = gql`
${MEDIA_FRAGMENT}
${PRODUCT_CARD_FRAGMENT}
query homepage($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
pageInfo: page(handle: "top") {
metafield(namespace: "top_page", key: "fv_video") {
createdAt
description
id
key
namespace
parentResource
reference
type
updatedAt
value
}
}
............
}
`;
const {data} = useShopQuery<{
pageInfo: Page;
heroBanners: CollectionConnection;
featuredCollections: CollectionConnection;
featuredProducts: ProductConnection;
}>({
query: HOMEPAGE_CONTENT_QUERY,
variables: {
language: languageCode,
country: countryCode,
},
preload: true,
});
const {
pageInfo: {metafield},
heroBanners,
featuredCollections,
featuredProducts,
} = data;
console.log(metafield);
/***
{
createdAt: '2022-08-01T03:31:31Z',
description: null,
id: 'gid://shopify/Metafield/***********',
key: 'fv_video',
namespace: 'top_page',
parentResource: {},
reference: {},
type: 'file_reference',
updatedAt: '2022-08-01T03:31:31Z',
value: 'gid://shopify/Video/***********'
}
***/