GraphQL error: Unknown argument 'deleted' on field 'removeFromPostsOnComments'

GraphQL error: Unknown argument 'deleted' on field 'removeFromPostsOnComments'

所以,我有一个从帖子到评论的一对多关系:

type Comments {
  createdAt: DateTime!
  deleted: Boolean
  id: ID!
  posts: Posts @relation(name: "PostsOnComments")
  text: String!
  updatedAt: DateTime!
  user: String!
}

type Posts {
  caption: String!
  comments: [Comments!]! @relation(name: "PostsOnComments")
  createdAt: DateTime!
  displaysrc: String!
  id: ID!
  likes: Int
  updatedAt: DateTime!
}

并希望 运行 突变,以及删除 post 和评论之间的连接,尝试更新字段 'deleted, on Comments, to true:

mutation removeComment ($id: ID!, $cid: ID!, $stateB: Boolean) {
  removeFromPostsOnComments (postsPostsId: $id, commentsCommentsId: $cid, deleted: $stateB){
    postsPosts {
      __typename
      id
      comments {
        __typename
        id
        text
        user
        deleted
        posts {
          __typename
          id
        }
      }
    }
  }
}
  
Query Variables

{
  "id": "cj0qkl04vep8k0177tky596og",
  "cid": "cj1de905k8ya201934l84c3id"
}

但是当我 运行 突变时,我收到以下错误消息:

GraphQL error: Unknown argument 'deleted' on field 'removeFromPostsOnComments' of type 'Mutation'. (line 2, column 74):
  removeFromPostsOnComments(postsPostsId: $id, commentsCommentsId: $cid, deleted: $stateB) {

正如向我解释的那样 ,只有帖子和评论之间的 link 被删除,而不是实际的 'Comment' 记录本身。所以我的想法是,既然没有删除记录,为什么我不能更新'deleted'字段呢?

我希望这样做以触发订阅,该订阅正在监视 updated 字段 'deleted'。

生成的变异输出如下:

  "data": null,
  "errors": [
    {
      "message": "Unknown argument 'deleted' on field 'removeFromPostsOnComments' of type 'Mutation'. (line 2, column 77):\n    removeFromPostsOnComments (postsPostsId: $id, commentsCommentsId: $cid, deleted: $stateB){\n                                                                            ^",
      "locations": [
        {
          "line": 2,
          "column": 77
        }
      ]
    }
  ]
}

如图所示,'deleted' 肯定包含在 'Comments' 我的 GraphCool 架构中:

我重现了你的问题。首先,您收到错误消息是因为 deleted 不是 removeFromPostsOnComments 突变参数的一部分,您还在文档中看到:

如果你想更新 Comments 类型的 deleted 字段,你必须使用 updateComments-mutation:

mutation {
  updateComments(id: "cj1de905k8ya201934l84c3id", deleted: true) {
    id
  }
}