gatsby-source-strapi
gatsby-source-strapi copied to clipboard
Gatsby build fails if content returned from Strapi is NULL
I'm using "gatsby": "2.18.4"
and "gatsby-source-strapi": "0.0.10"
.
The problem is that Gatsby build fails if the returned content is NULL. There are a few hacks, for example adding dummy data to every field, but that is not how it should be.
I have a big amount of content-types an dI do not want to add for every content type dummy data.
I have component where there can be 12 images, 12 titles, 12 descriptions, .... And if want to show only one, I need to add the other 11 images, titles, descriptions.
Any idea when will that be fixed?
Same issue, "gatsby": "^2.19.23"
and "gatsby-source-strapi": "0.0.10"
@alehuo That is BIG issue and nobody does anything. Nobody cares.
There are a few similar questions, but there is no solution.
As far as I know there will be a new gatsby strapi source plugin available in near future.
@Borisboky This is true for strapi and for all the gatsby data plugins, not only Strapi. It's not Strapi's fault. The official gatsby response is that you have to make sure that you have at least one field to avoid non-existant nodes in Graphql.
The thing that you're mentioning though doesn't make sense: did you use a repeater/array component? how the structure in your API is seeing, as an array, right? if that's the case, you only need 1 photo field/description.
Maybe if you post the structure we can help you.
btw, I'm moving to Strapi+Next.js because this very issue.
I got around this issue by explicitly writing some of the schema for parts of my Strapi content that are optional, as per this documentation: https://www.gatsbyjs.org/docs/schema-customization/
Not a perfect fix, but I thought I would share it anyway in case it helps someone.
This issue is very frustrating. For this and other reasons I recommend replacing gatsby-source-strapi with gatsby-source-graphql. So far it's a much better experience and totally fine with NULL values. I'm not sure what gatsby-source-strapi is supposed to provide that I can't do with gatsby-source-graphql. This does not seem like a production-ready plugin yet.
Thanks for your interest in this project. This plugin is moving into the Gatsby User Collective and this repo will be archived. Please open an issue in that repository, submit a PR if you'd like to see this implemented, or join us on Discord if you have questions!