Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi, I'm facing a problem on my developer's journey through Shopify's API :
I created a custom Storefront clien using '@shopify/shopify-api' in a NextJS application. When I try to query articles like this :
export default function getBodyProducts() {
return {
data: `{
products (first: 3) {
edges {
node {
id
handle
title
productType
publishedAt
}
}
}
}`,
}
}
let productsData = await storefrontClient.query(getBodyProducts())
I manage to get my products, however the id returned is not base64 encoded but a string of the actual ID ("gid://shopify/Product/7998956241136").
I don't know why it is returned as this because when using POSTMAN or curl, I get a base64 encoded ID.
The problem with that is that when I try to get the product medias, I get a "Variable $id of type ID! was provided invalid value" error when doing this (and giving the returned id as a variable) :
query: `query getProductMedia($id: ID!) {
product(id: $id) {
id
media(first: 10) {
edges {
node {
mediaContentType
alt
...mediaFieldsByType
}
}
}
}
}
I tryed coding the returned string in base64 and decode it before giving it to the media query but nothing seems to work. What can I do ?