Gatsby Contentful - ошибка запроса GraphQL: неизвестный тип "ContentfulFixed" - PullRequest
1 голос
/ 17 марта 2020

Я решил создать свой собственный блог и выбрал Gatsby-starter-mate EmaSuriano в качестве моего стартера Gatsby (я абсолютно новичок в Gatsby и Contentful!)

Я сделал все как было сказано, настроил свое окружение, настроил Contentful space и вошел в Contentful и так далее.

В настоящее время я нахожусь на Ubuntu 18.04 и

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

$ contentful --version
1.2.14

Все ниже успешно прошло без проблем

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

Но когда я

$ yarn start

и введите localhost: 8000 Я получаю Не удалось скомпилировать страницу с огромным количеством ошибок.

Я обратился к этой проблеме https://github.com/gatsbyjs/gatsby/issues/16455, чтобы решить мою проблему, и попробовал доступные там решения, такие как

  1. Удаление кодов во фрагментах. js file
  2. Удалить папку .cache
  3. Добавить фиктивный образ в мое пространство

Я также установил $ npm install --save gatsby-source-contentful. Сделал $ yarn add gatsby так же как $ yarn global add contentful-cli тоже.

Но ни один из них не сработал. Ниже моя ошибка, которая отображается на localhost: 8000 , когда я $ yarn start.
Может кто-нибудь, пожалуйста, помогите мне с этой проблемой? Большое вам спасибо!

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

Ответы [ 3 ]

0 голосов
/ 06 апреля 2020

Я поддерживаю этот пакет. Я играл с разными версиями зависимостей, проверяя, как они работают вместе, и обнаружил, что повышение версии gatsby на самом деле это то, что разрушает проект.

Пожалуйста, проверьте, используете ли вы версию "gatsby": "2.15.22", в ваши package.json, yarn.lock и node_modules.

Надеюсь, это поможет!

0 голосов
/ 04 мая 2020

Убедитесь, что у вас есть запись для каждого типа контента в contenful. Включая актив. Кажется, это проблема многих людей в этой теме .

0 голосов
/ 20 марта 2020

Это открытый вопрос, как обсуждено здесь . Попробуйте добавить и опубликовать любое изображение в медиа-ресурсах, которые могут решить проблему. Также попробуйте запустить

gatsby clean

перед запуском пряжи

...