Retrieving product image height and width using GraphQL API

Highlighted
Shopify Partner
7 0 2

I was initially using the REST API to retrieve the product images 

https://{{store}}.myshopify.com/admin/api/{{api_version}}/products/{{pid}}/images.json

I recently started using GraphQL and was not able to figure out a way to retrieve the same info

query Products($cursor: String, $query: String) {
    products(first: 20, after: $cursor, query: $query, sortKey:CREATED_AT, reverse: true) {
      pageInfo {
        hasNextPage
      }
      edges {
        cursor
        node {
          id
          title
          description
          createdAt
          images(first: 1) {
            edges {
              node {
                id
                originalSrc
                transformedSrc
              }
            }
          }
        }
      }
    }
}

Are there any image fields that can give me this info. I tried adding the fields maxHeight and maxWidth but got the response that these fields do not exist, even though it is mentioned as a field in the doc - https://shopify.dev/docs/admin-api/graphql/reference/object/image?api[version]=2020-04

1 Like
Highlighted
Shopify Partner
5 0 0

I'm having the same problem right now and it doesn't look like the GraphQL API has added this feature in the last couple of months.

https://shopify.dev/docs/admin-api/graphql/reference/object/image?api[version]=2020-10

I wonder if there's a way to add this to the Shopify feature queue.

0 Likes