해결된 질문
작성
·
368
0
Invariant Violation: Argument of undefined passed to parser was not a valid GraphQL DocumentNode. You may need to use 'graphql-tag' or another method to convert your operation into a document
This error happened while generating the page. Any console logs will be displayed in the terminal window.
이러한 에러가 뜨는데 왜 발생하는 걸까요.
const [contents, setContents] = useState("");
18 |
> 19 | const [나의함수] = useMutation(나의그래프큐엘셋팅)
| ^
20 |
21 | const onClickSubmit = async () => {
22 | const result = await 나의함수({
import { useState } from "react"
import {나의그래프큐엘셋팅} from './BoardWrite.queries' // export는 골라서 가져오기
import BoardWriterUI from "./BoardWrite.presenter"; // export-default로 한 개만 가져오기
import { useMutation } from "@apollo/client";
// import BoardWriterUI from "./BoardWrite.presenter"; // export-default로 한 개만 가져오기
// import BoardWriterUI, {apple} from "./BoardWrite.presenter"; // export-default와 export 함께 가져오기
// import * as S from './BoardWrite.styles' // 모든 export를 가져와줘
// S.BlueButton
// S.RedInput
export default function BoardWrite() {
const [writer, setWriter] = useState("");
const [title, setTitle] = useState("");
const [contents, setContents] = useState("");
const [나의함수] = useMutation(나의그래프큐엘셋팅)
const onClickSubmit = async () => {
const result = await 나의함수({
variables : { // variables 이게 $ 역활을 함
writer : writer,
title : title,
contents : contents
}
})
console.log(result)
}
const onChangeWriter = (event) => {
setWriter(event.target.value)
}
const onChangeTitle = (event) => {
setTitle(event.target.value)
}
const coChangeContents = (event) => {
setContents(event.target.value)
}
return (
<BoardWriterUI
aaa={onClickSubmit}
bbb={onChangeWriter}
ccc={onChangeTitle}
ddd={coChangeContents}/>
)
}
-컨테이너
import { gql } from "@apollo/client"
const 나의그래프큐엘셋팅 = gql`
mutation createBoard($writer : String, $title : String, $contents: String) {
createBoard(writer : $writer, title : $title, contents : $contents) {
_id
number
message
}
}
`
-쿼리
답변 1
0
하... 이런 실수를 감사합니다!!