javascript - 如何在使用 Gatsby.js 的 useStaticQuery 中使用内联片段?
问题描述
我想使用来自 gatsbyJs 和 Graphql 的 useStaticQuery 钩子来获取我的 github 中每个存储库的提交计数。收到此错误:Unknown type "Commit".
对于此查询:
const {
github: {
viewer: {
repositories: { edges },
},
},
} = useStaticQuery(
graphql`
{
github {
viewer {
repositories(first: 6, orderBy: { field: STARGAZERS, direction: DESC }) {
edges {
node {
stargazers {
totalCount
}
object(expression: "master") {
... on Commit {
history(first: 1) {
edges {
node {
committedDate
}
}
}
}
}
}
}
}
}
}
}
`
);
解决方案
推荐阅读
- python-3.x - pipenv shell 工作但显示错误
- c# - FluentMigrator 更新值不为空的列
- javascript - 按顺序将列表附加到每个 div
- vb.net - .NET 5.0 WinForms Button_Click 事件代码未运行和多个问题
- object - 为什么我得到“堆栈对象没有属性项”?
- python - 使用 Beautiful Soup 从主页访问所有元素
- javascript - 创建平滑的滚动效果
- excel - 如何根据另一个下拉列表单元格冻结 Excel 中的下拉列表单元格,并为其分配默认值?
- r - 带有ggplot的水平条形图:条的固定距离
- android - 添加产品风味以响应本机 android 项目