Shopify App Bridge - Product ResourcePicker - set initiaQuery for variants ID

leilei9011
New Member
2 0 1

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!

0 Likes
iain-campbell
Shopify Staff
Shopify Staff
54 9 20

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!

iain-campbell | Developer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog