How to Use Product Query GraphQL Magento 2?

Product Query GraphQL Magento contains a lot of information for a product.

You can fetch the result of the product query in multiple ways, Using Search Criteria with equal or match type, By full-text search within product query.

Pass only the required field on GraphQL Query so the output will be displayed only on those fields.

If you want to explore CMS GraphQL query, check the link, Get Cms Page and Cms blocks GraphQL Query.

Product Query Demo with multiple fields that will be displayed in the Output.

Given Query defines all the possible fields used for the product query but in real life, you can use the only required field inside the query.

In the given Product Query, We are expecting to return all the possible field that is used on the Products like,

  • Price Management,
  • Related,
  • Upsell,
  • Cross-Sell Products,
  • Tier Price,
  • Media Gallery Images,
  • Weight,
  • Product New From – To,
  • Custom Attributes of the Product,
  • Website Assignment,
  • Product Links,
  • URL Management,
  • Gift Messages,
  • Category Management.

Different ways to search product query,

1.) Products By Search: You can filter the Product by the direct full-text search with the query.

2) Product by FilterEqualTypeInput attribute:

‘eq’ keywords,

‘in’ keywords

3) Product by FilterMatchTypeInput attribute:

4) Product by FilterRangeTypeInput attribute:

You can filter either full text or match or equal by custom attribute type based on your project scope of work.