graphql - 如何让 Gatsby 插件内容可选字段工作?
问题描述
在 Contentful 的内容类型上有一个可选字段,我试图让 Gatsby-Plugin-Contentful-Optional-Fields 工作。
可选字段是一个图像,我使用新的 Gatsby-Image-Plugin 渲染。在 my 中配置插件后gatsby-config.js
,我仍然收到以下错误:
There was an error in your GraphQL query:
Cannot query field "description" on type "Node".
花了几个小时解决它,不幸的是没有成功。我对开发相当陌生,所以对其他人来说,也许只是一个明显的错误。非常感谢任何帮助。
我的 gatsby-config.js 中的插件配置:
{
resolve: "gatsby-plugin-contentful-optional-fields",
options: {
optionalFields: {
ContentfulNews: {
image: "Node",
},
},
},
},
我的查询:
query {
allContentfulNews(sort: { fields: date, order: DESC }) {
edges {
node {
id
heading
date(formatString: "DD.MM.YYYY")
text {
childMarkdownRemark {
html
}
}
image {
gatsbyImageData(
layout: FULL_WIDTH
placeholder: BLURRED
formats: [AUTO, WEBP]
quality: 100
width: 1500
)
description
}
}
}
}
}
解决方案
推荐阅读
- fortran - 如何从矩阵文本文件中读取特定列?不读整行?
- tensorflow - 如何在 Edge TPU 模型编译器上编译嵌入提取器?
- jquery - 在此代码中,如何将来自 URL 的 ID 与数据库中的 ID 进行比较,然后将数据显示到该特定 ID
- google-cloud-functions - Google IoT Core:我如何知道消息来自哪个设备?
- ios - 存储访问令牌的最佳实践
- css - 如何通过 CSS 更改背景图像的颜色?
- ios - StoreKit 如何跨设备同步非消耗品购买
- c# - += 是 C# 中的原子操作吗?
- flutter - GridView 的高度问题
- javascript - Firefox浏览器和手机上的无效日期错误