실습
게시판 만들기.03
이경찬 :)
2023. 1. 31. 10:51
gql을 이용하여 데이터를 보내주는 작업을 하였습니다.
const CREATE_BOARD = gql`
mutation createBoard($createBoardInput: CreateBoardInput!){
createBoard(createBoardInput: $createBoardInput){
_id
}
}
`
gql선언
createBoardInput: $createBoardInput : 변수값
$createBoardInput: CreateBoardInput!: 변수타입
// 쿼리문 적용
const [createBoard] = useMutation(CREATE_BOARD
const result = await createBoard({
variables: {
createBoardInput: {
writer: writer,
password: password,
title: title,
contents: contents
}
}
})
console.log(result)
onClickSubmit에 동기적으로 적용을 해주었습니다.