해결된 질문
작성
·
48
0
yarn codegen을 입력하면 이런 에러가 뜹니다 Not all operations have an unique name: fetchBoard:
success Saved 1 new dependency.
info Direct dependencies
└─ @graphql-codegen/cli@5.0.4
info All dependencies
└─ @graphql-codegen/cli@5.0.4
코드젠은 이렇게 잘 설치가 되었고
package.json 에도 이렇게 추가해 놓았습니다
"codegen": "graphql-codegen --config codegen.ts"
PS C:\Users\young\Desktop\frontend\class-example\my-app> yarn codegen
yarn run v1.22.22
warning ..\..\..\..\package.json: No license field
$ graphql-codegen --config codegen.ts
✔ Parse Configuration
❯ Generate outputs
❯ Generate to ./src/commons/graphql/
✔ Load GraphQL schemas
✔ Load GraphQL documents
⠏ Generate
[client-preset] the following anonymous operation is skipped:
mutation {
createBoard(writer: "윰", title: "작성중", contents: "내용작성중") {
_id
number
message
}
}
[client-preset] the following anonymous operation is skipped:
query {
fetchBoard(number: 1) {
number
writer
title
contents
}
}
[client-preset] the following anonymous operation is skipped:
query {
fetchBoard(number: 2) {
number
writer
title
contents
}
}
[client-preset] the following anonymous operation is skipped:
query {
fetchBoards {
number
writer
title
contents
}
}
[client-preset] the following anonymous operation is skipped:
query {
fetchBoards {
number
✔ Parse Configuration
⚠ Generate outputs
❯ Generate to ./src/commons/graphql/
✔ Load GraphQL schemas
✔ Load GraphQL documents
✖ Not all operations have an unique name: fetchBoard:
* fetchBoard found in:
- C:/Users/young/Desktop/frontend/class-examp…
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
답변 1
0
안녕하세요, 인프런 AI 인턴입니다.
윰이님께서 겪고 계신 문제는 GraphQL 코드 제너레이터를 사용하는 과정에서 발생한 오류입니다. 이 오류 메시지는 모든 GraphQL operation에 고유한 이름이 필요하다는 것을 나타냅니다. GraphQL에서 operation 이름은 고유해야 하며, 이름이 없는 (익명) 또는 중복된 이름이 있는 operation은 문제가 됩니다.
다음과 같은 해결 방법을 고려해 볼 수 있습니다:
query FetchBoard1 {
fetchBoard(number: 1) {
number
writer
title
contents
}
}
“`
이러한 조치를 취하면 코드젠 에러를 해결하는 데 도움이 될 것입니다. 더 자세한 내용을 알고 싶다면 GraphQL Code Generator 공식 문서를 참고하시길 바랍니다.
질문이 더 있다면 언제든지 문의해 주세요!