bagseye / barcadia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gatsby develop fails - "Cannot query field "references""

WebGuyJeff opened this issue · comments

commented

Great starter, thanks for sharing! ✌

I get this when running gatsby develop:

ERROR in 
/home/jeff/shadow/projects/barcadia-wordpress/src/pages/news/{contentfu
lPost.url}.js
  26:9  error  Cannot query field "references" on type
"ContentfulPostContent"  graphql/template-strings

I'm a Contentful noob, but as far as I can make out, references is reserved for paid Contentful plans, and as such the data isn't present upon syncing with a free account.

A quick fix for me was to remove this content from the Graphql query in src/pages/news/{contentfulPost.url}.js

Resulting in this:

export const data = graphql`
    query postQuery($id: String) {
        contentfulPost(id: { eq: $id }) {
        title
        introduction
        content {
            raw
        }
        createdAt(formatString: "DD MMMM, YYYY")
        }
    }
    `

Apart from one missing image, I haven't noticed any drastic impact and it's got me up and running.

References in this context relates to embedded assets in content (things like images...). It's different to the paid-for option you see in Contentful. The demo was built using the free version of Contentful so you shouldn't come across anything that is not available to you.

By the looks of it, graphql throws an error if none of the posts have embedded assets.

In my example one of the posts, Toolkit has an embedded asset, but the others do not so it does not cause an error. I'll need to test this theory locally but I imagine this is what is happening.

I'll need to see if there is a way of creating some sort of fallback, checking if none of the posts have embedded content as a way of preventing the error.

Thanks for the update, @bigupjeff. Resolved the errors on my end as well.

Image imports were hitting timeout limits resulting in missing referenced images causing fetch errors with 404's.

There was an error in your GraphQL query:
Cannot query field "references" on type "ContentfulPostContent"

Hi there. I had to remove the reference field from the query as well.
While I was messing with the post on Contentful, I figured the references field is a paid feature also.

@bagseye So is it possible to add images to a post in Contentful within the free plan?

Screen Shot 2022-05-14 at 00 34 04

I solved it 🥳🥳
Go to Contentful > Content Model > Post > Content (Rich Text) > Settings
Make sure the Asset is activated in the Embedded entries & assets.

And then the references field is enabled in the GraphiQL

Screen Shot 2022-05-14 at 11 44 34
Screen Shot 2022-05-14 at 11 47 37

@salihayazdir 's solution worked for me - BUT before it did, I had to add some media to one post

I'm getting the following errors :

(node:19866) MaxListenersExceededWarning: Possible EventEmitter memory leak
detected. 11 end listeners added to [PassThrough]. Use
emitter.setMaxListeners() to increase limit