export const CREATE_BOARD_COMMENT = gql`
mutation createBoardComment(
$createBoardCommentInput: CreateBoardCommentInput!
$boardId: ID!
) {
createBoardComment(
createBoardCommentInput: $createBoardCommentInput
boardId: $boardId
) {
_id
writer
contents
rating
createdAt
}
}
`;
const onClickCommentReg = async () => {
try {
await createBoardComment({
variables: {
createBoardCommentInput: {
writer,
password,
contents,
},
boardId: String(router.query.boardId),
},
});
alert("게시글 등록에 성공했습니다.");
} catch (error) {
alert("또 틀렸지롱~");
}
};
원인
garphql의 input 부분에 값을 variables에 안넣음
해결
contents 밑에 rating넣어주고 usestate로 만들어주고 router.push(/boards/${router.query.boardId}
) 만들어서 해결해주면 끝