Closed develo-pera closed 4 years ago
Hi Petar! Thanks for reaching out. Hopefully I can help! Two things:
Skus
in your Stripe account already?gatsby-config.js
?@njosefbeck thanks for the quick reply. Yes, the problem was that I didn't have products with SKUs in Stripe :( As soon as I added them everything was fine, so I'm going to close this issue.
What do you think about adding that information to the README.md?
I’m glad that resolved the issue! And yeah, adding this to the README seems like a good idea. If you want to do that and create a PR that’d be great! Otherwise I’ll get to it in a week or so. Thanks again! :)
Sent from my iPhone
On Nov 20, 2019, at 7:37 AM, Petar Popovic notifications@github.com wrote:
@njosefbeck thanks for the quick reply. Yes, the problem was that I didn't have products with SKUs in Stripe :( As soon as I added them everything was fine, so I'm going to close this issue.
What do you think about adding that information to the README.md?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Thanks @njosefbeck, I just opened a PR request #46 :)
@njosefbeck it would be nice to create the nodes even if there is not sku or no product. So the site can build fine
@D0m3- Hmm, my first thought is: why should nodes be created if there are no products or skus to create nodes from? If you have no products or skus, then remove them from the object
array for this plugin in your gatsby config. When you do have products / skus, add it back in.
Maybe I'm not considering your use case properly, so more details would probably help!
I have made some research and actually it seems like it's more a general Gatsby issue.
The use case is when you don't have any product then this error pops up at build time. It's a valid use case that a site doesn't have any product.
The easiest workaround is to create a dummy product, to make sure the api returns something, but filter it out in your queries.
You can also use createTypes
like that:
actions.createTypes(
`type StripeProduct implements Node {
id: ID!,
active: Boolean,
shippable: Boolean,
name: String,
created: Int,
metadata:Metadata,
images: [String],
description: String
}
`)
But you need to define all the fields that you are using and when you actually have products you might have conflicts. See my workaround there
Thanks for your response! After thinking about this for a day or so I had a couple of follow up thoughts:
I'm still not convinced that we need to make any updates to the plugin, but happy to discuss further. Thanks!
Thanks for your response! After thinking about this for a day or so I had a couple of follow up thoughts:
* If you're making an online store, you'll realistically have at least one product in Stripe, and thus when you query for products, you'll get something back. * If you're just testing out functionality and/or want a dummy product, you can also create one easily in the Stripe dashboard, that could be filtered out when querying. This would prevent you from having to do the above code-based workaround.
I'm still not convinced that we need to make any updates to the plugin, but happy to discuss further. Thanks!
I would like nodes to be created even if there is no data available in Stripe so that the build completes, and then I can handle the case of lacking data in my code. For my use case we have a shop that will usually only have a few items in it at a time and sometimes there may not be any items. Additionally, the shop is only one part of the website, but as it is right now if the shop doesn't have any products the entire website will fail to build. Ideally the shop would be able to handle this case on it's own without affecting the rest of the site.
Hello!
If someone in the community wants to attempt to tackle this issue, that works for me. I don't have the bandwidth at the moment. This also still might be a limitation of Gatby's?
Also, as stated above, you can still create a dummy product in Stripe and then filter it out when doing your graphql queries, to avoid any issues around building when you don't have any real products in your shop.
Apologies for not being able to dig into this further at the moment, but welcome further discussion / PRs!
I am also lacking bandwidth but I just came across a potential solution and thought of this issue.
Usually Gatsby infers GraphQL schema from the data. Without data Gatsby cannot add to the schema, and you can't query for something absent from the schema. Thus Cannot query...
Types can be created explicitly to work around this, see: Handle empty results in a Gatsby source plug-in & Customizing the GraphQL Schema
My understanding is that we would have to create types for every Stripe object (and all their attributes) in the case that there is no data to infer types from. stripe/openapi could be used for this purpose.
Prerequisites
Description
I read in one closed issue in the repo of the tutorial I followed that this can happen because of the wrong Stripe secret key, but I don't think that's the reason in my case. I've added the right secret key exactly as described here: https://www.gatsbyjs.org/tutorial/ecommerce-tutorial/, I've even hardcoded it and it still doesn't work, I rolled the secret key and tried with the new one and I have the same problem. I even created a new account and still the same.
Steps to Reproduce
gatsby-source-stripe
to your projectgatsby-config.js
Expected behavior: To have that query
Actual behavior: Graphql error
Unknown field 'allStripeSku' on type 'Query'.
Reproduces how often: Every time
Versions
os: macOs Mojave 10.14.5 node: 10.16.0 npm: 6.9.0 gatsby: 2.17.11 gatsby-source-stripe: 3.0.4
Additional Information
Here's the full log. Maybe this line can tell something
warn The gatsby-source-stripe plugin has generated no Gatsby nodes. Do you need it?