【问题标题】:Unable to remove deleted post in GraphQL无法在 GraphQL 中删除已删除的帖子
【发布时间】: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 中删除了,但我不知道为什么,因为我什么也没做。无论如何,再次感谢您的建议。

标签: reactjs graphql gatsby


【解决方案1】:

可能是结果被缓存了,试试运行gatsby cleanDocumentation.

【讨论】:

  • 感谢您的建议。过了一段时间,它从 GraphQL 中删除了,但我不知道为什么,因为我什么也没做。无论如何,再次感谢您的建议。
猜你喜欢
  • 2019-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-03
  • 1970-01-01
  • 2018-01-23
  • 1970-01-01
  • 2019-08-09
相关资源
最近更新 更多