How to fetch Product Image URLs using GraphQl Magento 2?

You can fetch the product images like Main Image, Thumbnail, Small Image, and Media Gallery Images URL by GraphQl.

You have to pass SKU in the product search query to get the product image URL.

GraphQl Query Request Body:

query{
  products(filter: { sku: { eq: "<SKU_NAME>" } }) {
    items {
      swatch_image
      small_image {
        url
        small_url
        medium_url
        large_url
      }
      thumbnail {
        url
        small_url
        medium_url
        large_url
      }
      image {
        url
        small_url
        medium_url
        large_url
      }
      media_gallery {
        url
        small_url
        medium_url
        large_url
      }
    }
  }
}

Replace <SKU_NAME> with your original SKU in the query request body.

Once you run the query, you will get the result as the URL of the product. If the specific image type is not found return as null otherwise result will be a full product image URL.

The media gallery returns the list of all the images of the product as an array.