2017-04-11 6 views
2

그래서, 내가 의견에 게시물에서 한 많은 관계가 있습니다GraphQL 오류 :에 알 수없는 인수 '삭제'필드 '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! 
 
}

을하고 돌연변이를 실행하려면, 뿐만 아니라, 게시물과 댓글 사이의 연결을 삭제하는 등의 필드를 업데이트하려고 시도하는 '댓글에, 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" 
 
}
,691 363,210

그러나 나는 다음과 같은 오류 메시지가 얻을 돌연변이 실행하면

으로

GraphQL error: Unknown argument 'deleted' on field 'removeFromPostsOnComments' of type 'Mutation'. (line 2, column 74): 
 
    removeFromPostsOnComments(postsPostsId: $id, commentsCommentsId: $cid, deleted: $stateB) {
이 게시물 사이에, 저 here에만 링크를 설명하고 삭제 댓글되었다, 실제 'Comment'레코드 자체는 아닙니다. 그래서 내 생각에, 레코드가 삭제되지 않으므로 '삭제 된'필드를 업데이트 할 수없는 이유는 무엇입니까?

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 
 
     } 
 
     ] 
 
    } 
 
    ] 
 
}

으로 이미지에서 볼 수 는, '삭제'확실히 '댓글'내 GraphCool 스키마에 포함되어

enter image description here

+0

어떻게 돌연변이가 서버에 생겼는데? –

+0

@ Locco0_0 돌연변이를 일으킨 결과물이 어떻게 생겼는지 궁금하다면 수정 된 질문을 참조하십시오. – TheoG

+0

GraphQL 오류는 삭제 된 인수를 서버의 돌연변이에 추가하지 않았 음을 나타냅니다. –

답변

3

문제가 재현되었습니다. 우선, deletedremoveFromPostsOnComments -mutation의 인수의 일부가 아니므로 오류 메시지를 받고있어, 당신은 또한 문서에 그 참조 :

enter image description here

을 당신이 deleted 필드를 업데이트하려면 Comments 유형에, 당신은 updateComments -mutation을 사용할 수 있습니다

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

설명에 많은 감사드립니다. – TheoG