inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[코드캠프] 부트캠프에서 만든 '완벽한' 프론트엔드 코스

10-1 API 타입 codegen 에러

해결된 질문

96

윰이

작성한 질문수 5

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.

react react-native 하이브리드-앱 graphql next.js

답변 1

0

인프런 AI 인턴

안녕하세요, 인프런 AI 인턴입니다.

윰이님께서 겪고 계신 문제는 GraphQL 코드 제너레이터를 사용하는 과정에서 발생한 오류입니다. 이 오류 메시지는 모든 GraphQL operation에 고유한 이름이 필요하다는 것을 나타냅니다. GraphQL에서 operation 이름은 고유해야 하며, 이름이 없는 (익명) 또는 중복된 이름이 있는 operation은 문제가 됩니다.

다음과 같은 해결 방법을 고려해 볼 수 있습니다:

  1. GraphQL 쿼리 또는 변형에 이름 추가:
    만약 익명으로 작성된 GraphQL 작업이 있다면, 각 작업에 명시적으로 이름을 부여해야 합니다. 예를 들어:
    ”`graphql
    mutation CreateBoard {
    createBoard(writer: “윰”, title: “작성중”, contents: “내용작성중”) {
    _id
    number
    message
    }
    }

query FetchBoard1 {
fetchBoard(number: 1) {
number
writer
title
contents
}
}
“`

  1. 코드 중복 확인:
    코드 내에서 동일한 이름을 가진 여러 operation이 있을 수 있습니다. 이러한 경우, 적절하게 이름을 변경하여 각각의 operation을 고유하게 만들어야 합니다.

이러한 조치를 취하면 코드젠 에러를 해결하는 데 도움이 될 것입니다. 더 자세한 내용을 알고 싶다면 GraphQL Code Generator 공식 문서를 참고하시길 바랍니다.

질문이 더 있다면 언제든지 문의해 주세요!

11강 23:35부터 막혀서 질문 드려요.

0

73

2

API 주소

0

84

1

하이브리드앱 과제 레퍼런스 코드

0

108

2

조건문, 반복문 너무 어려움

0

95

1

고농축 백엔드와 완벽한 프론트 강의 차이?

0

114

2

flex를 grid 처럼 만들기 질문드립니다.

0

93

2

유저 포인트 관련해서 질문 드립니다

0

70

1

npx create-react-app

0

93

1

fetchTravelproductsIPicked 관련 질문 드립니다

0

83

2

강의에서 사용하는 api 접속 불가

0

102

2

강의 커리큘럼에 대해 질문이 있습니다.

0

103

2

윈도우 -> 맥 파일 옮기기 / 실행

0

127

1

fetchUser 요청시 userPoint.amount

0

64

2

npm 배포 후 import 시 오류사항

0

90

2

koreanjson 관련 사이트가 접속이 안되요

0

68

2

17강 질문

0

85

2

tailwinde-css

0

73

2

04-02 Next 페이지 이동

0

80

2

[CSS&JS 마스터]공부하는 속도, 코드 리뷰

0

81

2

GRAPHQL 활용 과제

0

82

2

노란색 경고줄

0

53

1

181. [02-04] setState의 원리 질문

0

62

2

graphql 관련 질문입니다

0

66

2

node.js 설치방법

0

161

1