I have just spent ages implementing a solution to fetch a full list of values from a metaobject (up to 100) with GraphQL Storefront API.
For some context, my client has colour-based collections. I am already showing all colour variants of a product individually in collections and search results but for colour-based collections, it was no good to just show all of the colour variants of a product in these collections based on the parent product assignment to the collection so I needed to come up with a way to only show the x1 colour variant of a product in the collection for that colour.
All of the colours are set up in a metaobject. The collection metafield just references that metaobject list so it’s just a case of picking the colours that should show from a pre-defined list in the metafield.
Pagination wasn’t available (unsupported I believe) for metaobject values.
Fetching these in Liquid wasn’t an issue but was hitting the x50 limit so for collections where the client has listed more than x50 colours, only the first 50 were being detected meaning that any variants assigned to a colours after the 50th listed in the collection, the variant product cards weren’t displaying in the collection.
With a lot of battling, I successfully achieved this like:
Fetch full list in GraphQL script, expose these for global use in Liquid. Match these to variants of the products assigned to this collection. Display all variants and hide by default. Then unhide those that match and display as product cards. Conditional loading to only apply this to colour-based collections where colours have been populated otherwise fallback onto usual product loop for non-colour-based collections.
This was working great but after 20 minutes of client testing, the specific collection I had been testing in stopped working. And it turns out that the API is no longer returning any results.
This is affecting just ONE collection. There are several other colour-based collections still working fine using this same code/app.
I then discovered that this collection now shows ‘Excluded from Storefront API’ in the backend. All toggles for Storefront API access are still enabled for the collection metafields and metaobject. I have no idea why this has happened nor am I aware of any violation of API use.
Has anyone come across this and can shed any light?
I have already contacted Shopify and have to send them a ton of information about what I am trying to do etc so will do that but thought it might be worth sharing in here in case anyone knows more about this.
Thanks in advance