Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Get variants for products

Solved

Get variants for products

Snodgers
Shopify Partner
25 1 14

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
7 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 14

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
7 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 14

Thank you.

Snodgers
Shopify Partner
25 1 14

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
                        }
                    }
                }
            }
        }
    }
}