11
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gatsby.jsでgatsby-source-contentfulプラグインを使用するとUnknown type "ContentfulFixed".エラー

Posted at

エラー

Gatsby.jsでデータをContentfulからとってくるために、
gatsby-source-contentfulプラグインを利用して開発環境を立ち上げようとすると下記エラー。。。

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

どうやらfragment.jsに原因があるようだが見に覚えがない。
  

環境

今回エラーが出たバージョンはそれぞれ
Gatsby version: 2.15.6
gatsby-source-contentful: 2.1.31

  
  

解決策

海外フォーラムを見てると

Contentfulに適当に画像をアップロードするとエラーが解消された

という謎ソリューションが。
嘘だろと思いつつ、試してみると直った。。笑

  

以下解決までの流れ。

  1. 上部Navigationのmedia を選択
  2. 右上のAdd Assetから画像アップロード画面へ
  3. 適当な名前をつけて画像をアップロード

そして

yarn develop

すると直ってる!!
  
   
  
裏技的な解決法で本質的じゃない気がするけど...
エラー解消に苦労した & 海外フォーラムにしか解決策書いてなかったため共有です。

11
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?