menu

Saleor Commerce

The world’s fastest growing open-source e-commerce platform with billions of dollars transacted. Powered by Python, GraphQL, ReactJS and PWA.

Channels
# All channels
view-forward
# General
view-forward
# Announcements
view-forward
# Design
view-forward
# Development
view-forward
# Saleor 3.0
view-forward
# Saleor Features
view-forward
Team

Products getting repeat when trying to query all the products inside product…

July 14, 2020 at 9:11am

Products getting repeat when trying to query all the products inside product types

July 14, 2020 at 9:11am (Edited 29 days ago)
Hey guys, I'm trying to get all the products related to a specific product type name. But it looks like getting product repetition as the number of variants. so if i have 4 variants of product then it's getting repeat 4 times inside productTypes query.
This is how i'm using graphql query to achieve it.
productTypes(first: 1, filter: { search: "food" }) {
edges {
node {
name
products(first: 50) {
edges {
node {
name
}
}
}
}
}
}

July 14, 2020 at 7:46pm
I cannot reproduce this on https://pwa.demo.saleor.rocks/graphql/
Query:
{
productTypes(first: 1, filter: { search: "juice" }) {
edges {
node {
name
products(first: 50) {
edges {
node {
name
variants {
name
}
}
}
}
}
}
}
}
Results:
{
"data": {
"productTypes": {
"edges": [
{
"node": {
"name": "Juice",
"products": {
"edges": [
{
"node": {
"name": "Apple Juice",
"variants": [
{
"name": "1l"
},
{
"name": "2l"
},
{
"name": "500ml"
}
]
}
},
{
"node": {
"name": "Banana Juice",
"variants": [
{
"name": "1l"
},
{
"name": "2l"
},
{
"name": "500ml"
}
]
}
},
{
"node": {
"name": "Bean Juice",
"variants": [
{
"name": "2l"
},
{
"name": "500ml"
},
{
"name": "1l"
}
]
}
},
{
"node": {
"name": "Carrot Juice",
"variants": [
{
"name": "1l"
},
{
"name": "2l"
},
{
"name": "500ml"
}
]
}
},
{
"node": {
"name": "Coconut Juice",
"variants": [
{
"name": "500ml"
},
{
"name": "1l"
},
{
"name": "2l"
}
]
}
},
{
"node": {
"name": "Green Juice",
"variants": [
{
"name": "2l"
},
{
"name": "500ml"
},
{
"name": "1l"
}
]
}
},
{
"node": {
"name": "Orange Juice",
"variants": [
{
"name": "1l"
},
{
"name": "2l"
},
{
"name": "500ml"
}
]
}
},
{
"node": {
"name": "Pineapple Juice",
"variants": [
{
"name": "500ml"
},
{
"name": "2l"
},
{
"name": "1l"
}
]
}
},
{
"node": {
"name": "Power Juice",
"variants": [
{
"name": "500ml"
},
{
"name": "2l"
},
{
"name": "1l"
}
]
}
}
]
}
}
}
]
}
}
}
So only one product type found, no duplicates for products. You can check each product has multiple variants in it.
Can you reproduce issue using our demo? Is there difference between version you use and demo?
  • reply
  • like
I cannot reproduce this on https://pwa.demo.saleor.rocks/graphql/
Query:
{
productTypes(first: 1, filter: { search: "juice" }) {
edges {
node {
name
products(first: 50) {
edges {
node {
name
variants {
name
}
}
}
}
}
}
}
}
Results:
{
"data": {
"productTypes": {
"edges": [
{
"node": {
"name": "Juice",
"products": {
"edges": [
{
"node": {
"name": "Apple Juice",
"variants": [
{
"name": "1l"
},
{
"name": "2l"
},
{
"name": "500ml"
}
]
}
},
{
"node": {
"name": "Banana Juice",
"variants": [
{
"name": "1l"
},
{
"name": "2l"
},
{
"name": "500ml"
}
]
}
},
{
"node": {
"name": "Bean Juice",
"variants": [
{
"name": "2l"
},
{
"name": "500ml"
},
{
"name": "1l"
}
]
}
},
{
"node": {
"name": "Carrot Juice",
"variants": [
{
"name": "1l"
},
{
"name": "2l"
},
{
"name": "500ml"
}
]
}
},
{
"node": {
"name": "Coconut Juice",
"variants": [
{
"name": "500ml"
},
{
"name": "1l"
},
{
"name": "2l"
}
]
}
},
{
"node": {
"name": "Green Juice",
"variants": [
{
"name": "2l"
},
{
"name": "500ml"
},
{
"name": "1l"
}
]
}
},
{
"node": {
"name": "Orange Juice",
"variants": [
{
"name": "1l"
},
{
"name": "2l"
},
{
"name": "500ml"
}
]
}
},
{
"node": {
"name": "Pineapple Juice",
"variants": [
{
"name": "500ml"
},
{
"name": "2l"
},
{
"name": "1l"
}
]
}
},
{
"node": {
"name": "Power Juice",
"variants": [
{
"name": "500ml"
},
{
"name": "2l"
},
{
"name": "1l"
}
]
}
}
]
}
}
}
]
}
}
}
So only one product type found, no duplicates for products. You can check each product has multiple variants in it.
Can you reproduce issue using our demo? Is there difference between version you use and demo?
I'm using 2.10.1 version.
  • reply
  • like