today i run in a weird bug or whatever … actually i’m not able yet to identify the reason
on dev store i get null or empty array whatever query i run on product / collections
for instance:
query {product(handle:"product-handle") {id}}
return:
{
"data": {
"product": null
}
}
while fetching https://mytore.myshopify.com/products/product-handle.json work fine
the same for: query {collection(handle:"collection-handle") {id}}
and https://mytore.myshopify.com/collections/collection-handle.json
so my question is … i’m just doing something wrong like GQL have some hidden cap that rest does not have or i should keep using rest api because GQL it’s not stable yet?
ok recreate the storefront token worked for me
but i still have the same question … are Storefront GQL API stable or weird stuff like this may happen again?
Weird stuff happens with the Storefront API. I’ve been using the storefront API for some time now and between race conditions, slowness when it comes to mutations and weird bugs that “are expected behaviour”, I’ve learned that it’s not a very mature API and needs constant workarounds. Don’t get me wrong, it’s not bad, but just not as reliable as it should be for a customer-facing API.
Hey folks - I can’t say for sure without looking at the exact issues you’re seeing in the logs, but one reason why you could see different results between REST and the Storefront API is that REST is an Admin API and generally has wider access to shop information.
The Storefront API is designed to be a bit more granular and is focused on data representation for specific sales channels. So, for example, if you create a Storefront API app and it doesn’t have the product published to it, we’d return null values for queries for that product (same with collections, etc). I’d just make sure that your products are properly assigned to your Storefront API app as a sales channel and that you have the right scopes assigned to your token. There’s a bit more info here on how the unauthenticated access scopes work for the Storefront API:
And some more info on publishing products to a sales channel (through the Admin API):
The Storefront API is production-stable and used by many merchants, so this kind of thing is rare and usually points to a configuration issue rather than API instability. Hope this helps!