Get Product URL Rewrites data by GraphQL Magento 2.

Using GraphQL Magento, We can retrieve the product URL rewrites data in the response. If the specific product has multiple URL rewrite histories, The response will be multiple arrays with all the possible URL rewrite for a product.

You can create a query by SKU or Search by product name for GraphQL,

{
  products(filter: { sku: { eq: "24-WB04" } }) {
    items {
      name
      sku
      url_rewrites {
        url
        parameters {
          name
          value
        }
      }
    }
  }
}

Here, We are trying to load url_rewrites for the product by SKU. You can add your specified SKU value and the result will be displayed.

Response:

{
    "data": {
        "products": {
            "items": [
                {
                    "name": "Push It Messenger Bag",
                    "sku": "24-WB04",
                    "url_rewrites": [
                        {
                            "url": "push-it-messenger-bag.html",
                            "parameters": [
                                {
                                    "name": "id",
                                    "value": "14"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    }
}

You can see the result with available URL Rewrites for a given product.