njosefbeck / gatsby-source-stripe

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

Error "Cannot query field \"product\" on type \"StripePrice\"." #70

Open KabyleBOT opened 2 years ago

KabyleBOT commented 2 years ago

Prerequisites

[ ] Put an X between the brackets on this line if you have done all of the following:

Describe the bug When we try to query prices an error occures : { "errors": [ { "message": "Cannot query field \"product\" on type \"StripePrice\".", "locations": [ { "line": 9, "column": 9 } ], "extensions": { "stack": [ "GraphQLError: Cannot query field \"product\" on type \"StripePrice\".", " at Object.Field (D:\immal\immal.org\node_modules\graphql\validation\rules\FieldsOnCorrectTypeRule.js:48:31)", " at Object.enter (D:\immal\immal.org\node_modules\graphql\language\visitor.js:323:29)", " at Object.enter (D:\immal\immal.org\node_modules\graphql\utilities\TypeInfo.js:370:25)", " at visit (D:\immal\immal.org\node_modules\graphql\language\visitor.js:243:26)", " at validate (D:\immal\immal.org\node_modules\graphql\validation\validate.js:69:24)", " at graphqlMiddleware (D:\immal\immal.org\node_modules\express-graphql\index.js:98:38)", " at processTicksAndRejections (internal/process/task_queues.js:93:5)" ] } } ] }

To Reproduce Query : { allStripePrice { edges { node { id, object, active, billing_scheme, product, type, livemode, unit_amount, unit_amount_decimal, currency } } } }

image

Gatsby config: { resolve: gatsby-source-stripe, options: { objects: ["Product", "Price", "Plan"], secretKey: process.env.STRIPE_SECRET_KEY, downloadFiles: true, }, },

njosefbeck commented 2 years ago

Can you see if this is resolved in the latest version, and if it is then close this issue? Thanks!

mrmikardo commented 2 years ago

Hey at @KabyleBOT, I'm pretty sure that the issue here is that product is a field which needs to be expanded as per the screenshot below i.e. this is Not A Bug;

Screenshot 2022-01-04 at 21 47 45

@njosefbeck does this sound correct to you?

njosefbeck commented 2 years ago

Hi @mrmikardo! Thanks so much for following up here. So given the error (i.e. not being able to query the field at all), I do think there was an issue with querying the data in the first place (hence the error), but you're also right in that the GraphQL query should look more like yours, with product expanded.

After pushing up the most recent fix (as well as rewriting the GraphQL query to have product expanded), I'd be curious if @KabyleBOT found their issue resolved or not. And if not, we can dig in more to see if we can determine the root cause!

Thanks!