GraphQL: `product_id` not existing as field in `productVariant`

MikeZiegler
Shopify Partner
2 0 0

Hello community of Shopify Community Forum,

 

I have a problem with a request of mine, it outputs that a field, which was described in the documentation does not exist. Here is the link: https://shopify.dev/api/admin-graphql/2022-04/queries/productVariants#examples-Get_multiple_product_... 

 

I want to get a ProductVariant with the fields id, sku and product_id, but it throws me this error:

 

 

ClientError: Field 'productid' doesn't exist on type 'ProductVariant': {"response":{"errors":[{"message":"Field 'productid' doesn't exist on type 'ProductVariant'","locations":[{"line":8,"column":25}],"path":["query","productVariants","edges","node","productid"],"extensions":{"code":"undefinedField","typeName":"ProductVariant","fieldName":"productid"}}],"status":200,"headers":{}},"request":{"query":"\n        {\n            productVariants(first: 5, query: \"sku:'omg 245'\" ) {\n                edges {\n                    node {\n                        id\n                        sku\n                        productid\n                    }\n                }\n            }\n        }\n    "}}

 

 

Here is the Graphql request:

 

{
productVariants(first: 5, query: "sku:'${id}'" ) {
edges {
node {
id
sku
product_id
}
}
}
}

 

How can I solve this. Are there also alternatives?

Reply 1 (1)

MikeZiegler
Shopify Partner
2 0 0

Found a solution on Discord. I just had to replace `product_id` with

 

{
   product {
      id
   }
}