简体   繁体   English

Gatsby Contentful - GraphQL 查询错误:未知类型“ContentfulFixed”

[英]Gatsby Contentful - GraphQL query error: Unknown type "ContentfulFixed"

I've decided to build my own blog and chose EmaSuriano's gatsby-starter-mate as my Gatsby Starter (I am absolutely new to Gatsby and Contentful!)我决定建立自己的博客并选择EmaSuriano 的 gatsby-starter-mate作为我的 Gatsby Starter (我对 Gatsby 和 Contentful 完全陌生!)

I did everything as told, setting up my environment, setting up Contentful space and logged in to Contentful and so on.我按照指示做了所有事情,设置我的环境,设置 Contentful 空间并登录 Contentful 等等。

Currently, I am on Ubuntu 18.04 and目前,我在Ubuntu 18.04

$ gatsby --version
Gatsby CLI version: 2.10.10
Gatsby version: 2.19.45

$ contentful --version
1.2.14

Everything below suceeded without problem下面的一切都没有问题

$ gatsby new mate-portfolio https://github.com/EmaSuriano/gatsby-starter-mate  
$ yarn setup

But when I但是当我

$ yarn start

and enter localhost:8000 I get Failed to Compile page with huge amount of errors.并输入localhost:8000无法编译页面并出现大量错误。

I refered to this https://github.com/gatsbyjs/gatsby/issues/16455 issue to solve my problem and tried the solutions available there such as我参考了这个https://github.com/gatsbyjs/gatsby/issues/16455问题来解决我的问题并尝试了那里可用的解决方案,例如

  1. Delete codes in fragments.js file删除 fragment.js 文件中的代码
  2. Delete .cache folder删除 .cache 文件夹
  3. Add dummy image to my space将虚拟图像添加到我的空间

I also installed $ npm install --save gatsby-source-contentful .我还安装了$ npm install --save gatsby-source-contentful Did $ yarn add gatsby as well as $ yarn global add contentful-cli too. $ yarn add gatsby以及$ yarn global add contentful-cli是否也$ yarn add gatsby $ yarn global add contentful-cli

But none of them worked.但他们都没有工作。 Below is my error that shows on localhost:8000 when I $ yarn start .下面是我在localhost:8000上显示的错误,当我$ yarn start
Can anyone please help me with this issue?任何人都可以帮我解决这个问题吗? Thank you so much!非常感谢!

There was an error in your GraphQL query:

Unknown type "ContentfulFixed".

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

There was an error in your GraphQL query:

Unknown type "ContentfulFixed".

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

There was an error in your GraphQL query:

Unknown type "ContentfulFluid".

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

There was an error in your GraphQL query:

Unknown type "ContentfulFluid".

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

There was an error in your GraphQL query:

Unknown type "ContentfulResolutions".

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

There was an error in your GraphQL query:

Unknown type "ContentfulResolutions".

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

There was an error in your GraphQL query:

Unknown type "ContentfulResolutions".

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

There was an error in your GraphQL query:

Unknown type "ContentfulSizes".

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

There was an error in your GraphQL query:

Unknown type "ContentfulSizes".

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

There was an error in your GraphQL query:

Unknown type "ContentfulSizes".

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

There was an error in your GraphQL query:

Cannot query field "contentfulAbout" on type "Query".

If you don't expect "contentfulAbout" to exist on the type "Query" it is most likely a typo.
However, if you expect "contentfulAbout" 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 "contentfulAbout" 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 a 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". Visit our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/components/Helmet.js

There was an error in your GraphQL query:

Cannot query field "contentfulAbout" on type "Query".

If you don't expect "contentfulAbout" to exist on the type "Query" it is most likely a typo.
However, if you expect "contentfulAbout" 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 "contentfulAbout" 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 a 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". Visit our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/components/Footer.js

There was an error in your GraphQL query:

Cannot query field "contentfulAbout" on type "Query".

If you don't expect "contentfulAbout" to exist on the type "Query" it is most likely a typo.
However, if you expect "contentfulAbout" 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 "contentfulAbout" 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 a 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". Visit our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/sections/Landing.js

There was an error in your GraphQL query:

Cannot query field "siteMetadata" on type "Site".

If you don't expect "siteMetadata" to exist on the type "Site" it is most likely a typo.
However, if you expect "siteMetadata" 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 "siteMetadata" 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 a 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". Visit our docs to learn how you can define the schema for "Site":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/sections/Landing.js

There was an error in your GraphQL query:

Cannot query field "contentfulAbout" on type "Query".

If you don't expect "contentfulAbout" to exist on the type "Query" it is most likely a typo.
However, if you expect "contentfulAbout" 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 "contentfulAbout" 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 a 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". Visit our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/sections/Projects.js

There was an error in your GraphQL query:

Cannot query field "siteMetadata" on type "Site".

If you don't expect "siteMetadata" to exist on the type "Site" it is most likely a typo.
However, if you expect "siteMetadata" 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 "siteMetadata" 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 a 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". Visit our docs to learn how you can define the schema for "Site":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/sections/Writing.js

There was an error in your GraphQL query:

Cannot query field "allMediumPost" on type "Query".

If you don't expect "allMediumPost" to exist on the type "Query" it is most likely a typo.
However, if you expect "allMediumPost" 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 "allMediumPost" 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 a 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". Visit our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/sections/Writing.js

There was an error in your GraphQL query:

Cannot query field "mediumUser" on type "Query".

If you don't expect "mediumUser" to exist on the type "Query" it is most likely a typo.
However, if you expect "mediumUser" 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 "mediumUser" 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 a 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". Visit our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/sections/Writing.js

There was an error in your GraphQL query:

Cannot query field "contentfulAbout" on type "Query".

If you don't expect "contentfulAbout" to exist on the type "Query" it is most likely a typo.
However, if you expect "contentfulAbout" 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 "contentfulAbout" 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 a 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". Visit our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: /blog/src/sections/About.js

This is an open issue as discussed here .这是此处讨论的未决问题。 Try adding & publishing any image to media assets could potentially resolve the issue.尝试向媒体资产添加和发布任何图像可能会解决该问题。 Also try running也尝试运行

gatsby clean

before running yarn start在运行 yarn start 之前

I'm the maintainer of that package.我是那个包的维护者。 I was playing with different versions of the dependencies checking how they work together, and I found out that bumping the version of gatsby actually it's what it breaks the project.我在玩不同版本的依赖项,检查它们是如何协同工作的,我发现撞到 gatsby 的版本实际上是它破坏项目的原因。

Please check you are using the version "gatsby": "2.15.22", in your package.json , yarn.lock and node_modules .请检查您在package.jsonyarn.locknode_modules中使用的是版本"gatsby": "2.15.22",

Hope it helps!希望能帮助到你!

Make sure you have an entry for every content type in contenful.确保每个内容类型都有一个条目。 Including an asset.包括资产。 This seems to be many peoples problem in this thread .这似乎是这个线程中很多人的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM