【发布时间】:2020-08-24 05:03:33
【问题描述】:
我的代码有一些问题,我正在使用 Gatsby 和 Gatsby Awesome Pagination,
所以我不知道发生了什么,因为 gatsby develop 正在工作,但是当我使用时
gatsby build 上面写着
您的 GraphQL 查询中有一个错误: 所需类型“Int!”的变量“$id”没有提供。
这是我在 gatsby-node.js 中的代码
const BlogPosts = result.data.allWordpressPost.edges
paginate({
createPage,
items: BlogPosts,
itemsPerPage: 10,
itemsPerFirstPage: 10,
pathPrefix: '/blog',
component: path.resolve('./src/pages/blog.js'),
})
BlogPosts.forEach(post => {
createPage({
path: `/${post.node.slug}`,
component: BlogSinglePage,
context: {
id: post.node.wordpress_id,
},
})
})
这是我在 Blog.js 中的代码
export const query = graphql`
query ($skip: Int!, $limit: Int!) {
allWordpressPost(
skip: $skip
limit: $limit
)
{
edges {
node {
wordpress_id
title
excerpt
slug
date(formatString: "YYYY-MM-DD")
categories {
name
slug
}
featured_media {
source_url
}
}
}
}
}
`
你能告诉我我做错了什么
谢谢!!!
【问题讨论】: