Gatsby: Add the ability to query tags in gatsby-shopify-plugin

Created on 21 Feb 2019  路  2Comments  路  Source: gatsbyjs/gatsby

Summary

Using gatsby-source-shopify, is not possible to get the tags added to a product.
Shopify's GraphQL explorer _does_ support this. Use the following query to see an example:

{
  products(first: 10, reverse: true) {
    edges {
      node {
        title
        tags
      }
    }
  }
}

Basic example (proposal)

{
  allShopifyProduct {
    edges {
      node {
        tags
      }
    }
  }
}

Motivation

Having tags in the query would allow us to set up a of filtering system that would allow you to show sets of products inside a collection. It would also make it easier to render 'similar products' on a product page.

I am aware of ProductType but this can only have one single value. Tags are a bit more versatile.

bug

Most helpful comment

@wardpeet @DSchau I found the issue. tags breaks if none of the products you query for have a tag. Hope I didn't waste too much of your time. Thanks!

All 2 comments

I've looked into our Shopify source plugin and it seems like we query tags
https://github.com/gatsbyjs/gatsby/blob/d196205f23b84ccdde5d0d64d25d459b9b812b9b/packages/gatsby-source-shopify/src/queries.js#L110-L185

You should be able to get it. @DSchau you were looking into some shopify examples lately, anyway we can test this? ^^

@wardpeet @DSchau I found the issue. tags breaks if none of the products you query for have a tag. Hope I didn't waste too much of your time. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timbrandin picture timbrandin  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

rossPatton picture rossPatton  路  3Comments

hobochild picture hobochild  路  3Comments

ghost picture ghost  路  3Comments