The Readme states the following limitation:
At the moment, fields that do not have at least one populated instance will not be created in the GraphQL schema. This can break your site when field values get removed. You may workaround with an extra content entry with all fields filled out.
The fact that a site can break (does not build successfully) in those situations has turned out to be very annoying to me, even if it can be avoided by the mentioned workaround. And it makes optional fields on single types practically infeasible.
I think it should be feasible and would greatly improve the quality of the plugin. I didn't find any feature request or discussion on this topic, so I am raising it here.
Describe the solution you'd like
The plugin could explicitly generate data types based on the strapi schemas (which are already fetched here I think) before generating the nodes, e.g. using the createTypes hook (see Gatsby docs).
Describe alternatives you've considered
The alternative suggested in the Readme (create "an extra content entry with all fields filled out") feels like a hack. It doesn't work for single-types. It would feel more intuitive, if an optional field in Strapi, could be treated as an optional field in Gatsby, too.
The Readme states the following limitation:
The fact that a site can break (does not build successfully) in those situations has turned out to be very annoying to me, even if it can be avoided by the mentioned workaround. And it makes optional fields on single types practically infeasible.
I think it should be feasible and would greatly improve the quality of the plugin. I didn't find any feature request or discussion on this topic, so I am raising it here.
Describe the solution you'd like
The plugin could explicitly generate data types based on the strapi schemas (which are already fetched here I think) before generating the nodes, e.g. using the
createTypeshook (see Gatsby docs).Describe alternatives you've considered
The alternative suggested in the Readme (create "an extra content entry with all fields filled out") feels like a hack. It doesn't work for single-types. It would feel more intuitive, if an optional field in Strapi, could be treated as an optional field in Gatsby, too.