Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

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

leilei9011
Visitor
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!

Reply 1 (1)

iain-campbell
Shopify Staff (Retired)
54 9 23

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.