I’m trying to build a metaobject listing page with some simple filtering functionality. The issue here I’m facing is that, the @inContext Directive only works with Storefront API but only the Admin API works with the query argument. Is there any workaround to to build a filterable + translatable metaobject listing page with one fetch?
I can confirm that only the Storefront API works with the @inContext Directives, however the query argument filters are available on both the Admin and the Storefront APIs, but not for all queries. The query argument is implemented on a case by cases basis per API query.
Can you provide us with some more context on what you are trying to do exactly, and some details on the API calls you are currently using, and the ones that are insufficient for your use case, and we can definitely help look into it further and see if there’s any available workarounds.
I just wanted to reach out and see if you needed any further help with this still? If you can share any further questions or context into what you’re wanting to do exactly, we can help look into it and offer any potential solutions or workarounds possible. Otherwise we can go ahead and mark this thread as solved if you don’t need any further help with this.
To provide a bit more context, we’d like to retrieve a list of metaobject and filter them basing on field value with GraphQL. However it doesn’t seem to be possible with Storefront API. I’m getting the following error when I try to add a “query” object into the “variables”: Field 'metaobjects' doesn't accept argument 'query'
Looking at the documentation here, it also looks like only the Admin API takes the “query” arguement and we’d love to have it for the Storefront API too:
adminFilterable: Filter supported owner types based on metafield values for a definition in the Shopify admin and GraphQL Admin API.
The best workaround to this limitation, would be to simply use the Admin API to query and filter metaobjects directly instead of the Storefront API, alternatively as @Luke mentioned you can query for all metaobjects via the Storefront API and then filter the results on your end as well.
I understand this may not be ideal for your workflow and I will be submitting some feedback internally on your behalf that you’d like to see metaobject field filtering available on the Storefront API as well.
While I can’t guarantee when or if it would be added, I can assure you we do take all of our merchant and partner feedback with great value when determining future features and platform updates, and the more requests we get for features like these, the more likely and quicker it would be added.