如何使用contentful和gatsby检查graphql查询中的数据类型?
我有一个应用程序,它使用graphql和gatsby(作为ssr)从contentful获取数据,我的查询如下所示:如何使用contentful和gatsby检查graphql查询中的数据类型?,graphql,gatsby,contentful,Graphql,Gatsby,Contentful,我有一个应用程序,它使用graphql和gatsby(作为ssr)从contentful获取数据,我的查询如下所示: query MyQuery { allContentfulModelIntiveStory { nodes { ourValues { childContentfulPartFeatureSetLearnMoreOptionalTextTextNode { learnMoreOptionalText }
query MyQuery {
allContentfulModelIntiveStory {
nodes {
ourValues {
childContentfulPartFeatureSetLearnMoreOptionalTextTextNode {
learnMoreOptionalText
}
}
}
}
}
当learnMoreOptionalText
有一个值时,它工作正常,但当它为空时,我得到错误:
Cannot query field "childContentfulPartFeatureSetLearnMoreOptionalTextTextNode" on type "ContentfulPartFeatureSet".
为了解决这个问题,我需要在gatsby node.js
中配置数据库模式:
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions
const typeDefs = `
type ContentfulModelIntiveStory implements Node{
childContentfulPartFeatureSetLearnMoreOptionalTextTextNode: Node
} ...
我为它设置了节点
类型,但即使在删除缓存和重新启动服务器的情况下,它也无法工作,所以我的问题是,在哪里以及如何正确检查它的数据类型