Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Filters out child products (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwan-ep authored Jun 17, 2020
1 parent fc10207 commit dea3cba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ exports.createResolvers = ({ createResolvers }) => {
exports.createPages = async ({ graphql, actions: { createPage } }) => {
const pages = await graphql(`
{
allProducts: allMoltinProduct {
allProducts: allMoltinProduct(filter: {parent: {id: {eq: null}}}) {
edges {
node {
id
Expand Down
5 changes: 4 additions & 1 deletion src/templates/CategoryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export const query = graphql`
}
products: allMoltinProduct(
filter: { categories: { elemMatch: { id: { eq: $id } } } }
filter: {
categories: { elemMatch: { id: { eq: $id } } },
parent: {id: {eq: null}}
}
limit: $limit
skip: $skip
) {
Expand Down
6 changes: 5 additions & 1 deletion src/templates/CollectionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export const query = graphql`
}
products: allMoltinProduct(
filter: { collections: { elemMatch: { id: { eq: $id } } } }
filter: {
collections: {
elemMatch: { id: { eq: $id } } },
parent: {id: {eq: null}}
}
limit: $limit
skip: $skip
) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/ProductsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default ProductsList

export const query = graphql`
query allProductsQuery($limit: Int!, $skip: Int!) {
allMoltinProduct(limit: $limit, skip: $skip) {
allMoltinProduct(limit: $limit, skip: $skip, filter: {parent: {id: {eq: null}}}) {
edges {
node {
id
Expand Down

0 comments on commit dea3cba

Please sign in to comment.