Questions and discussions about using the Shopify CLI and Shopify-built libraries.
Hi all,
I'm using the "Product" type Resource Picker from Shopify App Bridge. However, I'm struggling to use variant Id as a field in the prop initialQuery to query on variants.
Can anyone help me on how to write the initialQuery to filter out specific variants by variant id?
Thanks so much!
hi leilei9011,
What‘s the task you’re trying to enable merchants to do? If you want to query variants only, you might want the product variant picker.
This isn't documented well, but the resource picker queries the GraphQL products resource (and the product variant picker queries the productVariants resource).
The initialQuery argument just allows you to pre-populate the query. There are some parameters available (check the links above), but filtering the products resource by variant ID isn’t one of them. If you're using a variant picker, you should be able to filter the query by multiple IDs using something like "1977803735096 OR 1557565866040 OR 1560131043384". You can read more about the search syntax used in this field here: https://shopify.dev/concepts/about-apis/search-syntax.
Hope this helps!
To learn more visit the Shopify Help Center or the Community Blog.