gatsbyjs / wp-gatsby

WordPress plugin for gatsby-source-wordpress
Other
167 stars 41 forks source link

Integration with WooCommerce Product Category Archives #234

Open craigwilcox opened 2 years ago

craigwilcox commented 2 years ago

At the moment, WP Gatsby incremental builds do not support WooCommerce Product Category archive changes. As with Issue #233 (https://github.com/gatsbyjs/wp-gatsby/issues/233), supporting these updates would be helpful to avoid clearing caches and rebuilding to update content.

When a product category is added or updated, an Action Monitor should detect the changes, clear the relevant caches, and rebuild archive pages. It should also detect changes to ACF fields used by category pages, as those are a helpful way to expand the functionality of the archive pages.

If there are hooks that are fired from the use of mutations on wpProductCategories, which should be more rare than single products, those should trigger the Monitor, as well.

Here is an example query our team uses to build product category archive pages:

{
    wpProductCategory(id: { eq: $productCategoryId }) {
      slug
      name
      description
      uri
    }
    allWpProductCategory(
      limit: $perPage
      skip: $offset
      filter: {
        wpParent: { node: { id: { eq: $productCategoryId } } }
      }
      sort: { fields: menuOrder, order: ASC }
    ) {
      nodes {
        name
        slug
        uri
        image {
          sourceUrl
          srcSet
          altText
          localFile {
            extension
            publicURL
            childImageSharp {
              gatsbyImageData
            }
          }
        }
        id
        slug
        termTaxonomyId: databaseId
        seo {
          metaDesc
          opengraphImage {
            sourceUrl
          }
        }
        wpChildren {
          nodes {
            id
            name
            uri
          }
        }
      }
    }
  }