Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

gatsby develop fails #4

Open
sparker888 opened this issue Jun 20, 2021 · 13 comments
Open

gatsby develop fails #4

sparker888 opened this issue Jun 20, 2021 · 13 comments

Comments

@sparker888
Copy link

Your site looks fantastic. I'm still learning Gatsby, but I've created two sites now using Contentful, so I know the basics. So, I have my space id and token set up properly. The develop fails with TypeError: Cannot read property 'products' of undefined and then multiple GraphQL errors as it appears to be looking for both Products and Features data. Does the data need to be populated into Contentful first for this to work? Thank you.

@bagseye
Copy link
Owner

bagseye commented Jun 20, 2021

Yes, I think it may require content, even dummy content for it to build. I'll probably need to to build in some sort of check the prevent future build problems but for the moment can you make some dummy content to see if that solves the errors

@sparker888
Copy link
Author

I don't have the time this week, but I will look at it again once I have another project rolling. It would be nice to get it working!

@chengjie0316
Copy link

I am facing the same problem , hey sparker had you solved it ??

@bagseye
Copy link
Owner

bagseye commented Nov 4, 2021

If it is the error previously reported, you will need to have some 'dummy content' in Contentful for it to build. There is a fix here - gatsbyjs/gatsby#32009 (comment) - to define types, but I don't have time to implement it right now.

@ibragimof
Copy link

I'm getting "product" pages and its widgets without pictures. Also all blog post coming with no picture from Contentful.
While gatsby develop got this error in bash:

ERROR #85923 GRAPHQL

There was an error in your GraphQL query:
Cannot query field "images" on type "ContentfulProducts".
If you don't expect "images" to exist on the type "ContentfulProducts" it is most likely a typo.
However, if you expect "images" to exist there are a couple of solutions to common problems: - If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server - The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have - You want to optionally use your field "images" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with that field ("dummy content") It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content".

Although all "Product" fields in Contentful are exists and therefore all pictures already must be imported with "product" module. Am I right?

@bagseye
Copy link
Owner

bagseye commented Dec 7, 2021

Yes, you need to have product images. It requires dummy content to render

@ibragimof
Copy link

Yes, you need to have product images. It requires dummy content to render

But I already have product images (which were imported with all demo content from your JSON file in start). Moreover, I see how all my "product" items displaying correctly in website. The only one problem -- pictures in blogs and products are missing.

All photo images lost while importing form Contentful.

@ibragimof
Copy link

My error about this event (from bash):

\src\templates\product-template.js
49:24 warning 'productImages' is assigned a value but never used no-unused-vars

@bagseye
Copy link
Owner

bagseye commented Dec 16, 2021

@ibragimof - did you resolve your issues?

@ibragimof
Copy link

Yes. Thanks.
Updated with your last commits.
It works for me now.

@ibragimof
Copy link

I've another question:
Contentful "product" item has field named "faq" (JSON content)
Untitled

and this field responses for creating an "accordion" in product pages.
nahw

Now I can't format this text inside of "FAQ" boxex. (in last picture it is an orange box). I want to start some lines from new line, create an active links etc.

In JSON field I already try to write "\n\r", markdown format etc... But it didn't works
Is any solution here?

@bagseye
Copy link
Owner

bagseye commented Dec 22, 2021

@ibragimof - Yea, that won't work. The implementation is very basic and was first put in around 2 years ago while I was still learning both Gatsby and Contentful.

I'm in the process of a major overhaul of this theme, creating new content models and changing the way it handles FAQs. The ideal implementation is a repeater field for FAQs but I've not started on it yet.

My suggestion in the meantime would be to look at creating your own Repeater field implementation with Contentful that replaces the JSON object approach.

@ibragimof
Copy link

ibragimof commented Dec 22, 2021

@bagseye I'll wait your new minor update )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants