Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatsby-source-contentful production build breaking if content is removed from Contentful field #2881

Closed
daniel-simpson opened this issue Nov 11, 2017 · 10 comments · May be fixed by tejzpr/gatsby#61

Comments

@daniel-simpson
Copy link
Contributor

os version: windows 10 (10.0.15063 Build 15063)
node version: v8.4.0
gatsby version: 1.9.108
gatsby-source-contentful version: 1.3.17

Summary

Production build breaks with a graphql schema error when Contentful optional field is empty in all entries.

success update schema — 0.100 s
⠂ extract queries from componentsTrace: GraphQLParser: Unknown field `price` on type `ContentfulGiftBox`. Source: document `boxQuery` file: `GraphQL request`.
    at graphqlError (C:\Projects\Supagifts\node_modules\gatsby\dist\internal-plugins\query-runner\graphql-errors.js:196:11)
...

Reproduction Steps

  1. Set up a basic site using gatsby-source-contentful
  2. Set up an optional (non required) field in Contentful
  3. Add data to this field in at least one entry
  4. Utilise this field in graphql layer
  5. Run gatsby build and note that site builds as expected.
  6. Remove data from the optional field
  7. Run gatsby build and note that the site build fails.

Notes:

I've started investigating this on a local PR branch, but need a little assistance in choosing an approach to fix, as I'm very new to graphql. Options:

  • In packages\gatsby-source-contentful\src\normalize.js, coalesce all field values (entryItemFields[entryItemFieldKey]) from null to an empty string or other flagged value.
  • Override gatsby-source-contentful's gatsby-node.js createPage behaviour
  • I've been reading through gatsby's graphql implementation but I'm not really able to make sense of whether there are any entrypoints for the gatsby-source-contentful to override this
@Chuloo
Copy link
Contributor

Chuloo commented Aug 29, 2018

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues as many of them have already been resolved with the latest updates or explained in a previous issue.

Feel free to open a new one if you still experience this problem or a similar one! 👍

@Chuloo Chuloo closed this as completed Aug 29, 2018
@agarrharr
Copy link
Contributor

I think it's fine to close this one. Issue #4847 is the same thing and it links to #4261 and #3344.

@Khaledgarbaya
Copy link
Contributor

Hey Folks,
I haven't tested this but this might be a p[otential Clean workaround that does not require creating dummy content.

https://medium.com/@Zepro/contentful-reference-fields-with-gatsby-js-graphql-9f14ed90bdf9

@cdtinney
Copy link
Contributor

cdtinney commented Apr 17, 2019

@Khaledgarbaya Doesn't seem to work with a single reference type (rather than one-to-many) since the field (contentSections in the example) doesn't exist in the schema at all.

@silviopaganini
Copy link

+1 watching this

@Glinkis
Copy link

Glinkis commented Jul 26, 2019

I'm also having this issue.

@dariobanfi
Copy link

Also having this issue

@iamkiko
Copy link

iamkiko commented Dec 3, 2019

Same here, deleting a post on contentful breaks the app. Any workarounds?

@gristleism
Copy link

Running into this issue as well.

@joakim-roos
Copy link

Running into this. Watching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet