[graphQL] query 날려보기

seokki kwon·2022년 8월 30일
0

graphQL

목록 보기
3/7
post-thumbnail

index.js

database에 supplice 라는 테이블에 쿼리를 날려보자


supplice 테이블의 구조

typeDef

const typeDefs = gql`
  type Query {
    teams: [Team]
    equipment: [Equipment]
    supplice: [Supplice]
  }
  type Team {
    id: Int
    manager: String
    office: String
    extension_number: String
    mascot: String
    cleaning_duty: String
    project: String
  }
  type Equipment {
    id: String
    user_by: String
    count: Int
    new_or_user: String
  }
  type Supplice {
    id: String
    team: Int
  } 
`

resolver

const resolvers = {
  Query: {
    teams: () => database.teams,
    equipment: () => database.equipments,
    supplice: () => database.supplies
  }
}

supplice 로 쿼리를 날리면
Supplice 에 정의된 객체가 배열형태로 반환됨

profile
웹 & 앱개발 기록

0개의 댓글