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

ERROR #85901 GRAPHQL | gatsby-source-contentful requires Media uploaded to work #15397

Closed
jingxuan98 opened this issue Jul 4, 2019 · 41 comments · Fixed by #24032
Closed

ERROR #85901 GRAPHQL | gatsby-source-contentful requires Media uploaded to work #15397

jingxuan98 opened this issue Jul 4, 2019 · 41 comments · Fixed by #24032
Labels
topic: GraphQL Related to Gatsby's GraphQL layer

Comments

@jingxuan98
Copy link

jingxuan98 commented Jul 4, 2019

Description

When I try to link my gatsby project with my self -created Contentful space, it shows this issue all the time

But when I try to link my gatsby to a contentful spaces with I created with their templates or examples, it runs fine

But for self created spaces, it shows this error....

Any solutions?

##Error Message

ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

Unknown type "ContentfulFixed". Did you mean "ContentfulSecondTry", "ContentfulContentType", or "ContentfulSecondTryEdge"?

Environment

I was in the latest gatsby-source-contentful and gatsby.

Any solutions?

@freiksenet
Copy link
Contributor

It's possible that you don't have any data for type Fixed in your self created space. Currently Contentful source needs data inside the types before it can generate it. We are fixing this in new version of contentful plugin, but currently you have to create something in your data table before it works.

@freiksenet freiksenet added status: awaiting author response Additional information has been requested from the author type: question or discussion Issue discussing or asking a question about Gatsby labels Jul 4, 2019
@andrew-secret
Copy link

I've got the same issue here

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Unknown type "ContentfulSizes". Did you mean "ContentfulPost", "ContentfulPostEdge", "ContentfulContentType", "ContentfulPostSortInput", or "ContentfulPostFieldsEnum"?

File: node_modules/gatsby-source-contentful/src/fragments.js:4:55

Can someone give me more information about it how I can fix this. I don't really get your response @freiksenet can you maybe explain it a bit further to me.. I'm just to dump to get it right now :(

@pieh
Copy link
Contributor

pieh commented Jul 4, 2019

@jingxuan98 @andrew-secret as temporary workaround, please add dummy image to contentful space. In #15344 (comment) one user said it works then.

@andrew-secret
Copy link

@pieh thanks I'll try it out and let you know if it worked out 👍

@andrew-secret
Copy link

andrew-secret commented Jul 4, 2019

@jingxuan98 @pieh I can confirm that it worked for me too... thank u soo much 💯

@folchi
Copy link

folchi commented Jul 4, 2019

@jingxuan98 @pieh confirmed. Uploading an image to "Media" resolved errors. Thanks!

@jingxuan98
Copy link
Author

Thanks guys!

@nmassi
Copy link

nmassi commented Jul 6, 2019

I don't have any media type in my content model. Is there any way to fix this without adding it?
Note: I've added a media type just with a dummy pic and it worked. However I would like not to do this.

@ffael
Copy link

ffael commented Jul 8, 2019

It worked for me too! Thanks @pieh

@maximechofflet
Copy link

I have the same error and I deleted all the content of the file: node_modules/gatsby-source-contentful/src/fragments.js and it's working.

@CRSantiago
Copy link

This worked for me as well!

@ryudice
Copy link

ryudice commented Aug 7, 2019

is this just going to be closed and not fixed? i dont think a workaround is considered a fix

@jamesncampbell
Copy link

Agree with @ryudice. Adding dummy data to my contentful space isn't an option. Just curious. I've used this package before without this issue. Anyone know how or when this bug was introduced?

@frontendmantra
Copy link

add dummy image also work for me

@brotzky
Copy link
Contributor

brotzky commented Aug 14, 2019

I'm reopening this issue as adding dummy data workaround isn't a fix.

I ran into the issue because i wanted to add gatsby-source-contentful as a theme option but will have to get the user to add their gatsby site.

It's especially frustrating because people that clone down an OSS (or any) the project now need to create contentful space and addd an image just because gatsby-source-contentful is in package.json.

@brotzky brotzky reopened this Aug 14, 2019
@lannonbr lannonbr added the topic: GraphQL Related to Gatsby's GraphQL layer label Aug 14, 2019
@kennylugo
Copy link

Tried what @maximechofflet mentioned and it worked, though it would randomly automatically break the app after 10 minutes.

@brotzky brotzky changed the title ERROR #85901 GRAPHQL ERROR #85901 GRAPHQL | gatsby-source-contentful requires Media uploaded to work Aug 18, 2019
@danecouzens
Copy link

@jingxuan98 @andrew-secret as temporary workaround, please add dummy image to contentful space. In #15344 (comment) one user said it works then.

Its worked for me, thank

@LekoArts
Copy link
Contributor

LekoArts commented Sep 23, 2019

Fixed by #12816

Please use the workarounds mentioned here or in the PR.

@patrickreynolds
Copy link

@pieh thank you!

If anyone was wondering what they meant by "adding dummy image there", follow these steps:

  1. Login to Contenify
  2. On the top navigation, select Media
  3. Upload any asset (I uploaded a 100px by 100px white square)
  4. Try rebuilding, and it just works

I have so many questions, but already wasted enough time on this to try to understand why that matters.

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Oct 23, 2019
@gatsbot
Copy link

gatsbot bot commented Oct 23, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 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. You can also add the label "not stale" to keep this issue open!

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! 💪💜

@LekoArts LekoArts added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Oct 25, 2019
@ericzorn93
Copy link

@pieh thank you!

If anyone was wondering what they meant by "adding dummy image there", follow these steps:

  1. Login to Contenify
  2. On the top navigation, select Media
  3. Upload any asset (I uploaded a 100px by 100px white square)
  4. Try rebuilding, and it just works

I have so many questions, but already wasted enough time on this to try to understand why that matters.

This has helped fix the issue temporarily. Thank you so much!

@JoshuaMaddox
Copy link

Not sure if this will work for others but I ran gatsby clean to clear the cache and it fixed this issue for me. I already had media assets in Contentful, however. The issue seems to reappear when I add new content. Clearing the cache again solves it for me.

MrT3313 pushed a commit to MrT3313/NoteCards that referenced this issue Dec 5, 2019
weird issue around gatsby-source-contentful needing an img saved in media in order to work
gatsbyjs/gatsby#15397
MrT3313 pushed a commit to MrT3313/NoteCards that referenced this issue Dec 10, 2019
* created: index.js as landingpage

created: AuthPage.js w/ initial sign in component

* added: TestPage / StudyPage / AuthPage / HomePage with initial layouts and styling structure

* added: GraphQL query to siteMetadata in getaby-config.js to render the app subTitle on the index.js page

* using GraphQL to access markdown data

* added: initial connection to Contentful CMS

weird issue around gatsby-source-contentful needing an img saved in media in order to work
gatsbyjs/gatsby#15397

* debug: structure of <HomePage /> & GraphQL Query

<HomePage /> is now dynamically rendering the <StudySetOption /> cards for each studySet recieved from the GraphQL query

* Refactored: <SidebarLayout />

component now accepts type prop
component is dyncamically rendering JSX for appropraite type
deleated individual component implementations of the SidebarLayout

* Updated: <StudySetOption />

styled updated to be rendering a stack of cards

* updated: <SidebarLayout /> css

* initial commit: auth branch

* step: initial app.js routing and rendering appropraite data

* Updated: Project file structure

broke Views our of Pages

* authReset // STUCK: cant resolve service worker

look into implementation of auth0 & gatsby without a typical react src/index.js

* auth: reset

* stage: basic rendering of <HomePage /> (src > app > views > HomePage.js) inside of <GATSBY_INDEX /> (src > pages > index.js)

* Updated: nodes.md

* auth0-gatsby starter project

* reNamed: account functionality to app

* auth0: V1 of integration working

started from a simple auth0-gatsby starter (https://github.com/auth0-blog/gatsby-auth0) project & adapted what I had previously done to integrate the contentful CMS into gatsby

* updated: ReadMe.md

* bug: .js.js changed to .js on a few pages

* updated: license
@LekoArts LekoArts removed status: awaiting author response Additional information has been requested from the author type: question or discussion Issue discussing or asking a question about Gatsby labels Dec 16, 2019
@tsmith123
Copy link
Contributor

An extra note on the "dummy image" - I believe you need to publish it too as it didn't work for me when in draft mode.

@lewi-g
Copy link

lewi-g commented Jan 22, 2020

Not sure if this will work for others but I ran gatsby clean to clear the cache and it fixed this issue for me. I already had media assets in Contentful, however. The issue seems to reappear when I add new content. Clearing the cache again solves it for me.

this has worked for me. Thank you.

@joshuagagne
Copy link
Contributor

joshuagagne commented Feb 22, 2020

Seems like this was introduced #15284 (assumption of prior support based on leftover comments).

// Check if there are any ContentfulAsset nodes and if gatsby-image is installed. If so,
// add fragments for ContentfulAsset and gatsby-image. The fragment will cause an error
// if there's not ContentfulAsset nodes and without gatsby-image, the fragment is useless.
exports.onPreExtractQueries = async ({ store, getNodesByType }) => {
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-contentful/src/gatsby-node.js#L243-L246

In the newer mode of query generation filtering out the gatsby-source-contentful fragments from creation inside the query-compiler.js removes the error.

https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/query/query-compiler.js#L137 on this line you can dump files=files.filter(d=>!d.includes('/gatsby-source-contentful/'))

just before the findGraphQLTags function in file-parser.js it seems reasonable it could also parse for some basic function that can once again check for the existence of assets in .cache/contentful/assets

@tsmith123
Copy link
Contributor

This issue has now returned for me.

@ghost
Copy link

ghost commented Apr 6, 2020

Hitting this issue again sadly.

@imelendez
Copy link

Hello, a google search for this error brought me here :)
ERROR #85901 GRAPHQL contentful

I added an image to contentful as mentioned above and also did clear cache as mentioned above at the same time!

So I can't share which one fixed it but the compilation errors went away and the project was successfully built.

@njbmartin
Copy link
Contributor

The dummy image is what fixed this issue for me. I don't use Contentful for images, so seems like an odd requirement to have at least one published image.

@efloreslb
Copy link

Tried gastby clean but that did not resolve issue. I can agree that adding a media asset removes the error.

@GeorgeSnitar
Copy link

It works for me too. Thanks )

@lappang-cheung
Copy link

Is there any development to this problem? I have the same issue if I don't upload a random picture to Contentful then it fails.

@pieh
Copy link
Contributor

pieh commented May 18, 2020

@lappang-cheung Did you try recent Gatsby version? gatsby@^2.21.29 might have a fix for it (assuming that you don't try to use those image fragments)

@Metashaker
Copy link

Creating an asset in the media tab also solved it for me

@accordingtoherr
Copy link

Getting this issue too=/ Already tried gatsby clean, adding an image - This is the error I am getting:
7:9 error Cannot query field "allContentfulBlogPost" on type "Query". Did you mean "allContentfulAsset", "contentfulAsset", or "allContentfulContentType"? graphql/template-strings

@Metashaker
Copy link

From the Contentful interface upload an image manually, restart your Gatsby developmente server, and you should be good to go 👍 .

@accordingtoherr
Copy link

accordingtoherr commented Jul 14, 2020 via email

@accordingtoherr
Copy link

accordingtoherr commented Jul 14, 2020 via email

@accordingtoherr
Copy link

accordingtoherr commented Jul 14, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: GraphQL Related to Gatsby's GraphQL layer
Projects
None yet