Re: Get variants for products

Solved

Get variants for products

Snodgers
Shopify Partner
25 1 13

Given this simple query to get the first ten products:

 

query {
  products(first: 10) {
    edges {
      node {
        id
        title
      }
    }
  }
}

How would I get their variants in the same query?

Accepted Solutions (2)

sanjuthakur
Shopify Partner
6 1 2

This is an accepted solution.

You need to add variants into the query just like you did for products

query {
products(first: 10) {
edges {
node {
id
title
variants (first: 10) {
edges {
node {
id
sku
barcode
}
}
}
}
}
}
}

View solution in original post

Snodgers
Shopify Partner
25 1 13

This is an accepted solution.

Here is a version of the answer is that is not painful to read:

 

query {
    products(first: 10) {
        edges {
            node {
                id
                title
                variants (first: 10) {
                    edges {
                        node {
                            id
                            sku
                            barcode
                        }
                    }
                }
            }
        }
    }
}

 

View solution in original post

Replies 3 (3)

sanjuthakur
Shopify Partner
6 1 2

This is an accepted solution.

You need to add variants into the query just like you did for products

query {
products(first: 10) {
edges {
node {
id
title
variants (first: 10) {
edges {
node {
id
sku
barcode
}
}
}
}
}
}
}

Snodgers
Shopify Partner
25 1 13

Thank you.

Snodgers
Shopify Partner
25 1 13

This is an accepted solution.

Here is a version of the answer is that is not painful to read:

 

query {
    products(first: 10) {
        edges {
            node {
                id
                title
                variants (first: 10) {
                    edges {
                        node {
                            id
                            sku
                            barcode
                        }
                    }
                }
            }
        }
    }
}