Skip to content

graphql 쿼리 예시

Minwook Je edited this page Feb 11, 2021 · 14 revisions

Place

{
  getPlacesByKeyword(filters: {
    query: "제주도 라면"
    
  }){
    id
    place_name
    category_name
    category_group_code
    category_group_name
    phone
    address_name
    road_address_name
    place_url
    distance
    x
    y
  }
}

Sticker

mutation {
  createSticker(createStickerInput: {
    place_id: "201796840"
    place_name: "할망라면"
    x: 126.525700988171
    y: 33.241145974544
    sticker_category: "당도70"    
  }){
		
    sticker_category
    is_used
    spot(populate:true){
      _id
      place_id
      stickers(populate:false){
        _id
      }
      place_name
      category_name
      category_group_code
      category_group_name
      phone
      address_name
      road_address_name
      place_url
      distance
      x
      y
    }
  }
}

spot

  • get all spots
{
spots{
  place_name
  category_name
  category_group_code
  category_group_name
  phone
  address_name
  road_address_name
  place_url
  distance
  x
  y
}
}
  • get spots by keyword
{
spots(searchSpotDto: {
  keyword: "라면"
}){
  place_name
  category_name
  category_group_code
  category_group_name
  phone
  address_name
  road_address_name
  place_url
  distance
  x
  y
}
}
  • get spots by keyword and (x,y)
{
spots(searchSpotDto: {
  keyword: "상점"
  x:127.069475150126
  y:37.2965566367321
}){
  place_name
  category_name
  category_group_code
  category_group_name
  phone
  address_name
  road_address_name
  place_url
  distance
  x
  y
}
}
  • spot 삭제
mutation {
  removeSpot(id: "6001ee99ca1c83001503ffd9") {
    n
  }
}

Course

  • 코스 생성
    • 스티커를 먼저 생성 한 뒤, 스티커들을 순서에 맞게 리스트에 넣어준다.
mutation {
  createCourse(createCourseInput: {
    stickers: ["60238405bc7cab131aa133b9","60238425bc7cab131aa133bb","60238440bc7cab131aa133bd"]
    title: "광교 데이트"
    is_share: false
  }){
    _id
    title
    is_share
    stickers

  }
}
  • 코스 이미지 url을 포함해서 정보 얻기
{
  course(courseInput: {
    courseId: "6023b7700d3e81506decd05e"
    courseImageInput: {
      theme: dark
      width: 700
      height: 700
    }
  }){
    _id
    stickers
    title
    is_share
    courseImage
  }
}
  • 위의 쿼리를 할경우 다음과 같은 response를 받게 됩니다.
{
  "data": {
    "course": {
      "_id": "6023b7700d3e81506decd05e",
      "stickers": [
        "6023b5033cf8244f7f830443",
        "6023b51b3cf8244f7f830445"
      ],
      "title": "광교 데이트2",
      "is_share": false,
      "courseImage": "https://api.mapbox.com/styles/v1/mapbox/dark-v10/static/path-4%2Bff512f(mvsbFqfqfWtGnAWhC),url-https%3A%2F%2Fuser-images.githubusercontent.com%2F37536298%2F107210367-5ff44b80-6a47-11eb-926f-ba9952911e92.png(127.069363534097,37.2978289663421),url-https%3A%2F%2Fuser-images.githubusercontent.com%2F37536298%2F107210367-5ff44b80-6a47-11eb-926f-ba9952911e92.png(127.067817114706,37.2964386614798)/auto/700x700?access_token=pk.eyJ1IjoibWlua2oxOTkyIiwiYSI6ImNra3F6eGxscjBuNzcyb21yM2N4N2JvZTcifQ.pUWQ8GYaWJXB0oE10Ukq1Q"
    }
  }
}

Clone this wiki locally