You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, fields that do not have at least one populated instance will not be created in the GraphQL schema.
If there doesn't exist an entry with a certain optional field, and the graphql query is expecting that field, then the gatsby build will break.
Here's our real world example:
We have our build triggered by a Contentful webhook whenever an Entry changes in contentful. Imagine we have some entries that have an optional field, eg, email. We add some entries with email populated, write our graphql queries and build the site, everything works.
One day, the content authors decided that they don't want to have the emails show on the frontend, so they delete the emails from all the entries. The webhook fires and it starts a build. At this point, no entry has an email in it, so the schema doesn't have email in it either. The graphql query was written to include an email, but it's no longer in the schema, so the build will break.
Our current workaround involves using gatsby-plugin-schema-snapshot and maintaining a whole host of stub content in Contentful that we need to publish every time we want to update any Contentful models and schema.gql. To say the least, it's not a very efficient workflow.
The "At the moment" in the documentation suggests this might change in the future. Is it on the roadmap to include all possible fields in the graphql schema to avoid this situation? Is it possible to build the schema based on the model instead of the data?
Steps to reproduce
Create a Contentful model with a name and email.
Create an entry with just a name (leave email blank)
Run project and open graphiql, email is not available in graphql
Expected result
All possible fields should be available in graphql, including email
Actual result
Only name is available
The text was updated successfully, but these errors were encountered:
Description
I'd like to have optional fields in my Contentful models. The problem is stated on https://www.gatsbyjs.com/plugins/gatsby-source-contentful/:
If there doesn't exist an entry with a certain optional field, and the graphql query is expecting that field, then the gatsby build will break.
Here's our real world example:
We have our build triggered by a Contentful webhook whenever an Entry changes in contentful. Imagine we have some entries that have an optional field, eg,
email
. We add some entries withemail
populated, write our graphql queries and build the site, everything works.One day, the content authors decided that they don't want to have the emails show on the frontend, so they delete the emails from all the entries. The webhook fires and it starts a build. At this point, no entry has an
email
in it, so the schema doesn't haveemail
in it either. The graphql query was written to include an email, but it's no longer in the schema, so the build will break.Our current workaround involves using gatsby-plugin-schema-snapshot and maintaining a whole host of stub content in Contentful that we need to publish every time we want to update any Contentful models and
schema.gql
. To say the least, it's not a very efficient workflow.The "At the moment" in the documentation suggests this might change in the future. Is it on the roadmap to include all possible fields in the graphql schema to avoid this situation? Is it possible to build the schema based on the model instead of the data?
Steps to reproduce
name
andemail
.name
(leaveemail
blank)email
is not available in graphqlExpected result
All possible fields should be available in graphql, including
email
Actual result
Only
name
is availableThe text was updated successfully, but these errors were encountered: