【发布时间】:2020-05-18 09:16:42
【问题描述】:
使用 Gatsby 和 Contentful 创建博客。我删除了有关 Contentful 的帖子,但该帖子仍在 GraphQL 上显示。我有什么方法可以自动从 GraphQL 服务器中删除已删除的帖子?
我尝试了 Mutation,但它对我不起作用。
export const query = graphql`
query($skip: Int!, $limit: Int!) {
allContentfulPost(
sort: { fields: [publishDate], order: DESC }
limit: $limit
skip: $skip
) {
edges {
node {
title
id
slug
publishDate(formatString: "DD MMM YYYY")
heroImage {
title
fluid(maxWidth: 1800) {
...GatsbyContentfulFluid_withWebp_noBase64
}
}
body {
childMarkdownRemark {
html
excerpt(pruneLength: 80)
}
}
}
}
}
}
`
export default Index
query MyQuery {
contentfulBlogPost {
id
}
allContentfulPost {
edges {
node {
id
title
slug
}
}
}
}
这是我要从 GraphQL 中删除的节点。
{
"node": {
"id": "4e6323f0-87c9-53a3-b1bb-e357d8ae578f",
"title": "test",
"slug": "tesrt"
}
},
【问题讨论】:
-
你又跑
gatsby build了吗? -
感谢您的建议。过了一段时间,它从 GraphQL 中删除了,但我不知道为什么,因为我什么也没做。无论如何,再次感谢您的建议。