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

Cannot query field "bodyRichText" on "ContentfulBlogPost" using gatsby-source-contentful v4.6.4 #33323

Closed
2 tasks done
justsilencia opened this issue Sep 28, 2021 · 10 comments · Fixed by #34083
Closed
2 tasks done
Assignees
Labels
status: awaiting author response Additional information has been requested from the author topic: source-contentful Related to Gatsby's integration with Contentful type: bug An issue or pull request relating to a bug in Gatsby

Comments

@justsilencia
Copy link

justsilencia commented Sep 28, 2021

Preliminary Checks

Description

** EDIT ** I created a repo here that reproduces this error even with the latest version of gatsby and gatsby-source-contentful

I'm using gatsby-source-contentful v4.6.4 in a blog I'm working on with gatsby.

I have blog posts already on contentful CMS, and I'm able to query everything EXCEPT my rich text successfully.

In the GraphiQL interface in the browser, or in the project itself, I get the following message when I try to use bodyRichText.

**Cannot query field "bodyRichText" on type contentfulBlogPost **

Here is an example of a basic query I'm tring to use:

{
  contentfulBlogPost(id: {eq: "4e95d2aa-f051-52f6-a906-279e5ea5a9a2"}) {
    bodyRichText {
      raw
          references {
                 ... on ContentfulBlogPost {
		      contentful_id
                 }
      }
    }
  }
}

I can do something even more simple, such as this:

query MyQuery {
      contentfulBlogPost {
	id
            bodyRichText {
		raw
              }
        }
 }

And I still get the same result.

Reproduction Link

https://github.com/justsilencia/gatsby-contentful-rt-error

Steps to Reproduce

  1. Open graphIql or create query in component using gatsby-source-contentful v4.6.4
  2. Try querying bodyRichText

...

Expected Result

To receive formatted rich text from gatsby-source-contentful v4.6.4 plugin via graphql query.

Actual Result

Error: Cannot query field "bodyRichText" on type contentfulBlogPost

Environment

System:
    OS: Windows 10 10.0.18363
    CPU: (6) x64 Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
  Binaries:
    Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.18362.449.0)
  npmPackages:
    gatsby: ^2.32.3 => 2.32.13 
    gatsby-image: ^2.11.0 => 2.11.0 
    gatsby-plugin-image: ^1.0.0 => 1.8.0 
    gatsby-plugin-manifest: ^2.12.0 => 2.12.1 
    gatsby-plugin-offline: ^3.10.0 => 3.10.2 
    gatsby-plugin-react-helmet: ^3.10.0 => 3.10.0 
    gatsby-plugin-sharp: ^2.14.1 => 2.14.4 
    gatsby-source-contentful: ^4.6.2 => 4.6.4 
    gatsby-source-filesystem: ^2.11.0 => 2.11.1 
    gatsby-transformer-remark: ^2.16.0 => 2.16.1 
    gatsby-transformer-sharp: ^2.12.0 => 2.12.1

Config Flags

No response

@justsilencia justsilencia added the type: bug An issue or pull request relating to a bug in Gatsby label Sep 28, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Sep 28, 2021
@justsilencia justsilencia changed the title Cannot query field "bodyRichText" on time "ContentfulBlogPost" Cannot query field "bodyRichText" on "ContentfulBlogPost" using gatsby gatsby-source-contentful v4.6.4 Sep 28, 2021
@justsilencia justsilencia changed the title Cannot query field "bodyRichText" on "ContentfulBlogPost" using gatsby gatsby-source-contentful v4.6.4 Cannot query field "bodyRichText" on "ContentfulBlogPost" using gatsby-source-contentful v4.6.4 Sep 28, 2021
@LekoArts LekoArts added topic: source-contentful Related to Gatsby's integration with Contentful and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Oct 4, 2021
@github-actions
Copy link

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 github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Oct 24, 2021
@justsilencia
Copy link
Author

Has anyone been able to at least confirm this issue by chance?

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Nov 3, 2021
@wardpeet
Copy link
Contributor

wardpeet commented Nov 8, 2021

cc @axe312ger

@axe312ger
Copy link
Collaborator

Do you have actual content in your Rich Text field? If not, you run into the bug we try to fix via #31385

Also, v4.6.4 is for Gatsby v2. There have been significant bugfixes in the source plugin and Gatsby itself since that release. Please consider migrating to more up to date versions of the plugin & core.

@LekoArts LekoArts added the status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. label Nov 8, 2021
@LekoArts
Copy link
Contributor

Hi!

Since we didn't receive an answer for 7 days or more about the ask of a reproduction I'm going to close this now, as we can't do much to help without a reproduction. If you are able to create a minimal reproduction for this then please do answer here or open a new issue with a reproduction. Thanks!

@justsilencia
Copy link
Author

justsilencia commented Nov 25, 2021

@axe312ger and @LekoArts thanks for the reply. Apologies for my delayed response. For some reason github didn't notify me of your comments.

In case you didn't notice, I already edited the post on 9/29/21 and added a link to a very simple repo I created that reproduces this issue even with the latest version of gatsby. So in response to your comment, unfortunately this issue persists well beyond 4.6.4. And yes, there is indeed actual content in the rich text fields.

I would humbly ask that this issue be reopened, since it is unresolved and I have provided a minimal reproducible example on or about the time of the OP.

Thanks guys.

@axe312ger axe312ger reopened this Nov 25, 2021
@axe312ger
Copy link
Collaborator

I'll have a look. Thanks for the repo

@axe312ger axe312ger self-assigned this Nov 25, 2021
@axe312ger
Copy link
Collaborator

axe312ger commented Nov 25, 2021

@justsilencia:

I installed your repo. It works fine for me:

Screenshot 2021-11-25 at 09 18 58

You logs above show Gatsby v2. The version of gatsby-source-contentful that is compatible with Gatsby v2 might have some rich text bugs. Your example repo uses "gatsby-source-contentful": "^5.14.0", which should be alright for rendering rich text.

Edit:

Might it be the case, that your field is called blogPost and not bodyRichText? To avoid issues like this, I usually compose my queries in http://localhost:8000/___graphql and then copy them to my code as soon I am happy with the query results

@axe312ger axe312ger added status: awaiting author response Additional information has been requested from the author and removed status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. labels Nov 25, 2021
@justsilencia
Copy link
Author

justsilencia commented Nov 25, 2021

@axe312ger I think I may have misunderstood the docs. Your comment about the field name triggered an 'oh I'm an idiot' moment. When reading the docs, it gives bodyRichText as a field. I thought it was a special function of the contentful plugin that simplifies (or trims) the returned rich text in an easier to use manner.

This discussion on github about Gatsby and contentful rich text helped reinforce this notion.

However, it seems that bodyRichText is simply a placeholder name for whatever the name of your rich text field is. If this is the case, sorry; I pretty much wasted your time.

@axe312ger
Copy link
Collaborator

No worries! Thats how the plugin works. Each of your Contentful fields will be turned into a Gatsby GraphQL field.

I gonna update the README to make it more clear :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting author response Additional information has been requested from the author topic: source-contentful Related to Gatsby's integration with Contentful type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants