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

未入力のフィールドがある場合にビルドエラーが起きる #4

Open
shibe97 opened this issue Jul 7, 2020 · 2 comments

Comments

@shibe97
Copy link
Member

shibe97 commented Jul 7, 2020

概要

microCMSのフィールドとして定義しているが、入稿画面で未入力のデータがあるとビルドエラーが起きる場合がある

リスト形式の場合

特定のフィールドがリスト内で全て存在していない場合にエラーが発生する

オブジェクト形式の場合

特定のフィールドが存在していない場合にエラーが発生する

@shibe97
Copy link
Member Author

shibe97 commented Jul 7, 2020

他のヘッドレスCMSプラグインでも同様の問題が起きている。
gatsbyjs/gatsby#2392

@shibe97
Copy link
Member Author

shibe97 commented Jul 7, 2020

gatsby-node.jsにて下記のようにスキーマのデフォルト定義を行うことで回避ができる。

例:gatsbyobjectAPIにて、title, imageを任意設定にしたい場合

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions
  const typeDefs = `
    type MicrocmsGatsbyobject implements Node {
      title: String
      image: Image
    }
    type Image {
      url: String
    }
  `
  createTypes(typeDefs)
}

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

No branches or pull requests

1 participant