【发布时间】:2020-07-16 09:03:24
【问题描述】:
我很想用 Gatsby 创建自己的网站。第一次使用graph-ql,我用Gatsby服务的graph-ql ide查询了收集SiteMeatadata
const data = useStaticQuery(graphql`
query SiteInformationQuery {
__typename
site {
siteMetadata {
author {
name
summary
}
title
description
}
}
}
`);
我预测它会像这样返回
{
"data": {
"site": {
"siteMetadata": {
"title": "Gatsby Typewriter theme",
"author": {
"name": "dodok8",
"summary" : "student"
}
}
}
}
}
但它出错了。
ERROR #85901 GRAPHQL
There was an error in your GraphQL query:
Field "author" of type "SiteSiteMetadataAuthor" must have a selection of subfields. Did you mean "author { ... }"?
File: src\components\seo.js:21:13
但我在查询中设想了author 的所有子文件。我的子字段和查询语句有什么问题?
它是关于存储在gatsby-config.js 中的siteMetadata 的原始数据。
module.exports = {
siteMetadata: {
title: `Gatsby Typewriter theme`,
description: `Demo page of Gatsby Typewriter theme`,
author: {
name: 'dodok8',
summary: 'student',
},
},
【问题讨论】: