Solved

How can I obtain Product gid from ProductVariant gid using GraphQL?

rattlesnakeMT
Shopify Partner
27 2 1

I need to grab the Product gid, but in the cart I only see ProductVariant gid. Which is fine, if there is a way I can look up the Product gid from GraphQL. Having troubles with queries. I've been going with node and trying to do a fragment. Not sure if I'm on the right path or not.

 

Hank D
Accepted Solution (1)
rattlesnakeMT
Shopify Partner
27 2 1

This is an accepted solution.

I was able to actually get it via nodes lookup

 

query MyQuery {
	  nodes(ids: "$inVariantID") {
	    ... on ProductVariant {
	      id
	      product {
	        id
	      }
	    }
	  }
	}

 

Hank D

View solution in original post

Replies 2 (2)

Crowly
Shopify Partner
65 3 5

I'd be happy to help!

What API are you currently using to acces products in the cart. Pixel? Cart API?

Convert more customers with AI-powered, automated conversion rate optimization.
️ Free plan now available!
https://apps.shopify.com/crowly
rattlesnakeMT
Shopify Partner
27 2 1

This is an accepted solution.

I was able to actually get it via nodes lookup

 

query MyQuery {
	  nodes(ids: "$inVariantID") {
	    ... on ProductVariant {
	      id
	      product {
	        id
	      }
	    }
	  }
	}

 

Hank D