How to Get Related Product GraphQL Query Magento 2?

Related Product GraphQL Query to retrieve all the related items of the specific product by GraphQL in Magento 2.

If any products have assigned related products and want to fetch all the related items using GraphQL query, you need to use given Payload to check the output,

You need to first investigate the Product GraphQL before jump into this article by Use Product Query GraphQL Magento.

Related Product GraphQL Query:

You can check the related_products{} the field in the product query to retrieve all the related products.

If the product has Related products assigned, the output will be all the assigned products array with related_products keys otherwise its display as an empty array.

You can also add other required fields to the output. I have used only a few of the fields to display in the output.

This is the basic example of Related Products GraphQL Query in the Magento world.

You can also interested to read GraphQL Query,

  1. How to Get Cross Sell Product GraphQL Query Magento 2?
  2. How to Get Upsell Product GraphQL Query Magento 2?