Giter VIP home page Giter VIP logo

Comments (8)

njosefbeck avatar njosefbeck commented on June 15, 2024 1

Yay, I'm glad that it worked out for you! Let me know if you run into any other issues and I'll be happy to help debug.

from gatsby-source-stripe.

njosefbeck avatar njosefbeck commented on June 15, 2024

Hello!

So at the moment the plugin doesn't support getting the optimized image in nested products (like in your example where the Product is nested inside of Price). As a workaround though, you can query for all products, which will include references to the optimized images on the localFiles key and then in JavaScript match up the product by id with the price. Not ideal, but that's the best I've got at this time!

If someone wants to attempt to add this functionality, please create a PR. I don't have the time to do it myself in the foreseeable future, but would happy to review anything someone comes up with. And if you need help crafting a query / solution based on what I describe above, let me know! Thanks!

from gatsby-source-stripe.

ammonialime avatar ammonialime commented on June 15, 2024

Hey @njosefbeck

Thanks for getting back to me on this. Much appreciated.

I'm looking at my options in GraphiQL and I don't see a way to query for products without being nested in AllStripePrice. I've attached an image of my GraphiQL below. I assume I'm missing something... Can you give me an idea as to what the query would look like?

Screen Shot 2021-05-23 at 8 26 06 PM

from gatsby-source-stripe.

njosefbeck avatar njosefbeck commented on June 15, 2024

Hello! So if you add 'Product' to the gatsby-config options for this plugin (so then your array of Stripe objects would be ['Price', 'Product'], you'll then see allProduct when you re-run npm start. Let me know if you experience issues with that and I can add a more thorough example!

from gatsby-source-stripe.

ammonialime avatar ammonialime commented on June 15, 2024

Got it!

Looks like that is going to work.

So basically query both the price for price data and the product data for the images and cross reference them based on the id field to put the data together for each product component?

Appreciate all your help! Will see if I can get it up and running tomorrow.

from gatsby-source-stripe.

ammonialime avatar ammonialime commented on June 15, 2024

Got this working this morning based on your advice.

Cross referenced the product id from the product object and price object and pulled the local images data that way.

Brought the site to 99/100 on lighthouse from mid 80s. Makes a big difference. Thanks again.

from gatsby-source-stripe.

ruteckimikolaj avatar ruteckimikolaj commented on June 15, 2024

Hey @ammonialime! 2 years passed and I am facing same issue :) Could you be so kind and provide detailed example how you did that ? I am more backend developer and I presume I am missing something here how did you fetched all of the images to be availble for the gatsby-image plugin.

from gatsby-source-stripe.

AndreaDiotallevi avatar AndreaDiotallevi commented on June 15, 2024

You can now fetch optimised images directly from allStripePrice like this:

  1. Install gatsby-source-stripe

  2. Configure package in gatsby-config.js (make sure downloadFiles is set to true):

 {
        resolve: `gatsby-source-stripe`,
        options: {
                objects: ["Price"],
                secretKey: process.env.GATSBY_STRIPE_SECRET_KEY,
                downloadFiles: true,
        },
 },
  1. Query optimised images from localFiles:
export const query = graphql`
    {
        allStripePrice {
            edges {
                node {
                    active
                    id
                    unit_amount
                    product {
                        id
                        name
                        localFiles {
                            childImageSharp {
                                gatsbyImageData(
                                    width: 310
                                    quality: 99
                                    layout: CONSTRAINED
                                    placeholder: BLURRED
                                )
                            }
                        }
                    }
                }
            }
        }
    }
`

from gatsby-source-stripe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.