njosefbeck / gatsby-source-stripe

Gatsby source plugin for building websites using Stripe as a data source
74 stars 17 forks source link

Linking products and SKUs #1

Closed all9lives closed 6 years ago

all9lives commented 6 years ago

I'm building some e-commerce functionality, pulling product data from stripe. Is there a way to link products and skus together? Since we need to pull information like description etc from the product API and things like price etc from the SKU api.

Ideally we could make a query like this.

{
  allStripeSku {
    edges {
      node {
        id
        active
        price
        products {
          id
          name
          description
        }   
      }
    }
  }
}

Is something like this possible, or would I need to chain several queries to get the product which belongs to a sku?

njosefbeck commented 6 years ago

Hello!

Currently this isn't possible, but I'm looking into setting it up so that all Stripe objects would be auto-expanded: https://stripe.com/docs/api#expanding_objects. This would then allow you to get the full product information under a sku. I'll update this issue once I've finished updating my code.

njosefbeck commented 6 years ago

@all9lives - So I think I've successfully got this working. I've tested it and it works locally. Feel free to npm install gatsby-source-stripe the latest version and let me know if you run into any issues: https://www.npmjs.com/package/gatsby-source-stripe

all9lives commented 6 years ago

@njosefbeck Thanks for adding that in, it works great.