gatsby-source-strapi icon indicating copy to clipboard operation
gatsby-source-strapi copied to clipboard

Gatsby build fails if content returned from Strapi is NULL

Open Borisboky opened this issue 4 years ago • 7 comments

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?

Borisboky avatar Mar 02 '20 07:03 Borisboky

Same issue, "gatsby": "^2.19.23" and "gatsby-source-strapi": "0.0.10"

alehuo avatar Mar 03 '20 13:03 alehuo

@alehuo That is BIG issue and nobody does anything. Nobody cares.

There are a few similar questions, but there is no solution.

Borisboky avatar Mar 04 '20 07:03 Borisboky

As far as I know there will be a new gatsby strapi source plugin available in near future.

tomolenet avatar Mar 05 '20 14:03 tomolenet

@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.

kyuumeitai avatar May 07 '20 18:05 kyuumeitai

btw, I'm moving to Strapi+Next.js because this very issue.

kyuumeitai avatar May 07 '20 18:05 kyuumeitai

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.

denforlatte avatar Jun 07 '20 18:06 denforlatte

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.

ballPointPenguin avatar Aug 16 '20 16:08 ballPointPenguin

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!

moonmeister avatar Dec 27 '22 18:12 moonmeister