[GraphQL] Parent Resolver

jw·2022년 12월 30일

GraphQL

목록 보기
4/4
post-thumbnail

resolver는 4개의 인자를 받을 수 있다.
그 중 첫 번째 인자를 parent라고 한다.

parent는 부모 resolver에서 반환된 객체이다.


//typeDefs

  type Hashtag {
    id: Int!
    hashtag: String!
    photos(page: Int!): [Photo]
    totalPhotos: Int!
  }

//resolvers 

 Hashtag: {
    photos: (parent) => {
      console.log(parent);
    },

photos resolver의 parent는 Hashtag resolver이다.


console.log(parent) 출력결과

{id:1, hashtag:"#hi"}
profile
다시태어나고싶어요

0개의 댓글