Any way to gracefully fail GraphQL queries? #28680
-
Hey folks - first off, thanks for creating such a great dev product & community! Loving Gatsby so far. I'm curious if there's a way for GraphQL queries to fail gracefully vs. breaking the build. My project uses the GitHub GraphQL API and occasionally we hit their rate limit. I'm wondering if there's a way to have our API request fail gracefully (e.g. by returning empty results) vs. causing the entire build to fail when the API returns a 403 response code? Here's an example of a broken build in Netlify:
Full logs can be found here. Here's an example of the error when running
I'm still able to run the app locally when this error takes place but trying to Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Is this with gatsby-source-graphql? |
Beta Was this translation helpful? Give feedback.
-
We are going to add a new section in docs about this. Not published yet but you can check it here: |
Beta Was this translation helpful? Give feedback.
-
Hey @KyleAMathews @vladar - thanks again for your replies here. I'm digging back into this now & following this code example: https://www.gatsbyjs.com/plugins/gatsby-source-graphql/#composing-apollo-links-for-production-network-setup Current problem is I hit this error:
When I try to import ApolloLink in my gatsby-configs.js with
...I hit this new error:
Including Any further guidance here is greatly appreciated 🙏 I tried upgrading to latest version of |
Beta Was this translation helpful? Give feedback.
-
FYI we ended up going with the batching approach mentioned in the Gatsby docs to solve this: Here's our PR for reference: Thanks folks! |
Beta Was this translation helpful? Give feedback.
FYI we ended up going with the batching approach mentioned in the Gatsby docs to solve this:
https://www.gatsbyjs.com/plugins/gatsby-source-graphql/#performance-tuning
Here's our PR for reference:
ethereum/ethereum-org-website#2295
Thanks folks!