gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.25k stars 10.32k forks source link

[gatsby-source-contentful] Cannot query field "references" on type #28729

Closed daydream05 closed 3 years ago

daydream05 commented 3 years ago

Description

After updating to the latest gatsby-source-contentful@4.3.0 from the canary version we are getting this error.

Cannot query field "references" on type "contentfulBlogPostBodyRichTextNode".

If you don't expect "references" to exist on the type "contentfulBlogPostBodyRichTextNode" it is most likely a typo.
However, if you expect "references" to exist there are a couple of solutions to common problems:

We've been using the new rich text for awhile now and this was bit of a surprise.

@jordan314 Also encountered this issue from this thread

Expected result

What should happen?

Gatsby should recognize references from rich text fields

Actual result

It doesn't understand what they are.

Environment

System: OS: macOS High Sierra 10.13.6 CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 14.10.1 - /usr/local/bin/node Yarn: 1.16.0 - ~/.yarn/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 87.0.4280.88 Firefox: 83.0 Safari: 13.1.2 npmPackages: gatsby: ^2.24.50 => 2.29.1 gatsby-image: ^2.4.16 => 2.8.0 gatsby-plugin-amplitude-analytics: ^3.2.0 => 3.2.0 gatsby-plugin-mailchimp: ^5.2.2 => 5.2.2 gatsby-plugin-manifest: ^2.4.28 => 2.9.0 gatsby-plugin-next-seo: ^1.6.1 => 1.6.1 gatsby-plugin-offline: ^3.2.24 => 3.7.0 gatsby-plugin-react-helmet: ^3.3.10 => 3.7.0 gatsby-plugin-react-svg: ^3.0.0 => 3.0.0 gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0 gatsby-plugin-sharp: ^2.6.28 => 2.11.1 gatsby-plugin-sitemap: ^2.4.12 => 2.9.0 gatsby-plugin-theme-ui: ^0.3.0 => 0.3.5 gatsby-plugin-web-font-loader: ^1.0.4 => 1.0.4 gatsby-source-contentful: ^4.3.0 gatsby-source-filesystem: ^2.3.25 => 2.8.0 gatsby-transformer-remark: ^2.12.0 => 2.13.0 gatsby-transformer-sharp: ^2.5.13 => 2.9.0 npmGlobalPackages: gatsby-cli: 2.12.91

daydream05 commented 3 years ago

Ok so this is really frustrating.

I found a solution:

If you want to use hyperlink in rich text that refers to an entry, you need to have a dummy content that accounts for ALL the references. So if you're referring to a blog post, a page or guide, you need to create a hyperlink of each one on these options. So imagine having so many RTFs in your different content models, you have to create multiple hyperlinks inside of each one if you ever wanna query these references on your frontend.

Having a embedded dummy content for rich text is a bit annoying cause it's a lot of manual work on Contentful side.

alana314 commented 3 years ago

Yes we've found this issue too. We also had to create sample content for each rich text field. Limiting the types of content you can include in the contentful validation helps how many queries you have to write. We're also looking into seeing if we can manually add nodes with these types of links into the codebase so that we don't have to have these sample items in the CMS.

filiptammergard commented 3 years ago

Yep, this is annoying. I also created some dummy content to be able to query the references, which works, but it feels kind of dumb.

fabiosanto commented 3 years ago

+1 I spend two hours on this :/

github-actions[bot] commented 3 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

daydream05 commented 3 years ago

For folks that are running into this issue:

You need to:

  1. Create "dummy" content in your rich tex field hyperlinks. Basically if you use rich text on any of your content model and you plan to hyperlink another content model, you need to create samples this for EVERY reference you're trying to query.
erictaylor commented 3 years ago

I'm trying to upgrade and migrate to the new RTF and I can not for the life of me get the references field to show up.

All my content types with a RTF show no references field in GraphiQL.

Suggestions in this thread seem to suggest "dummy" content in Contentful but is vague at best on what exactly that means.

I have "dummy" content for each Content Type that has a RTF that adds several different "Entity" hyper links, and embeds an asset and I still can't get the field to show up.

What am I doing wrong? The README and migration information need updated badly to explain how to get this to work.

github-actions[bot] commented 3 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

github-actions[bot] commented 3 years ago

Hey again!

It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜