A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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?
Solved! Go to the solution
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
}
}
}
}
}
}
}
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
}
}
}
}
}
}
}
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
}
}
}
}
}
}
}
Thank you.
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
}
}
}
}
}
}
}