練習graphql-API


Playground<-練習リンク
チョルスの年齢は何歳ですか.△年齢のみを調べてください.Input
query {
fetchProfile(name: "철수") {
  age
  }
}
Output
{
  "data": {
    "fetchProfile": {
      "age": 20
    }
  }
}
英姫の学校はどこですか.△学校だけ調べてください.Input
query {
fetchProfile(name: "영희") {
  age
  }
}
Output
{
  "data": {
    "fetchProfile": {
      "school": "다람쥐초등학교"
    }
  }
}
  • 3番の投稿の内容と作成日は何ですか?(内容と記入日のみを照会してください.)
  • Input
    query {
      fetchBoard(number: 3) {
        contents
        createdAt
      }
    }
    Output
    {
      "data": {
        "fetchBoard": {
          "contents": "냉무",
          "createdAt": "2021-07-07T05:23:28.118Z"
        }
      }
    }
  • 本人の名前で履歴書に記入してください.
  • Input
    mutation {
      createProfile(name: "Chungsik", age: 20, school: "KAIST"){
        message
      }
    }
    Output
    {
      "data": {
        "createProfile": {
          "message": "프로필이 정상적으로 등록되었습니다."
        }
      }
    }
  • 本人の名前で投稿を書いてください.
  • Input
    mutation {
      createBoard(
        writer: "Chungsik"
        password: "1234"
        title: "This is a title."
        contents: "These are contents."
      ) {
        message
        number
      }
    }
    Output
    {
      "data": {
        "createBoard": {
          "message": "게시물이 정상적으로 등록되었습니다.",
          "number": 71
        }
      }
    }
  • 自分の個人情報を調べてください.
  • Input
    query {
      fetchProfile(name: "Chungsik"){
        # number
        name
        age
        school
      }
    }
    Output
    {
      "data": {
        "fetchProfile": {
          "name": "Chungsik",
          "age": 20,
          "school": "KAIST"
        }
      }
    }
    自分の投稿
  • を調べてください.
  • Input
    query {
      fetchBoard(number: 71){
        number
        writer
        title
        contents
        like
        createdAt
      }
    }
    Output
    {
      "data": {
        "fetchBoard": {
          "number": 71,
          "writer": "Chungsik",
          "title": "This is a title.",
          "contents": "These are contents.",
          "like": 0,
          "createdAt": "2021-07-07T08:41:27.584Z"
        }
      }
    }
  • 本人の履歴書で、学校を卒業した小学校に変えた.
  • Input
    mutation {
      updateProfile(name: "Chungsik", age: 20, school: "POSTECH"){
        # _id
        # number
        message
      }
    }
    Output
    {
      "data": {
        "updateProfile": {
          "_id": null,
          "number": null,
          "message": "프로필이 정상적으로 수정되었습니다."
        }
      }
    }
  • 本人の投稿で、タイトルと内容を変更してください.
  • Input
    mutation {
      updateBoard(
        number: 71
        writer: "Chungsik"
        # password: "1234"
        title: "This is an edited title."
        contents: "These are modified contents."
      ) {
        # _id
        # number
        message
      }
    }
    Output
    {
      "data": {
        "updateBoard": {
          "message": "게시물이 정상적으로 수정되었습니다."
        }
      }
    }
  • 自分の好きな漫画の主人公で履歴書を書きましょう.
  • Input
    mutation {
      createProfile(name: "Pororo", age: 19, school: "EBS") {
        message
      }
    }
    Output
    {
      "data": {
        "createProfile": {
          "message": "프로필이 정상적으로 등록되었습니다."
        }
      }
    }
  • の上位10ビットのプロファイルを削除します.
  • Input
    mutation {
      deleteProfile(name: "Pororo") {
        message
      }
    }
    Output
    {
      "data": {
        "deleteProfile": {
          "message": "프로필이 정상적으로 삭제되었습니다."
        }
      }
    }
  • の商品を作ってみます.
  • Input
    mutation {
      createProduct(
        seller: "Chungsik"
        createProductInput: {
          name: "Nike Jordan 1"
          detail: "Nike X Dior Collaboration Model"
          price: 600
        }
      ) {
        _id
        message
      }
    }
    Output
    {
      "data": {
        "createProduct": {
          "_id": "f8f63f1b-39d1-477c-950f-8ce32a3bc8c4",
          "message": "상품이 정상적으로 등록되었습니다."
        }
      }
    }
  • 位12位で作った商品の価格を500元引き上げる.
  • Input
    mutation {
      updateProduct(
        productId: "f8f63f1b-39d1-477c-950f-8ce32a3bc8c4"
        updateProductInput: {
          name: "Nike Jordan 1"
          detail: "Nike X Dior Collaboration Model"
          price: 1100
        }
      ) {
        message
      }
    }
    Output
    {
      "data": {
        "updateProduct": {
          "message": "상품이 정상적으로 수정되었습니다."
        }
      }
    }
  • で作成された商品を検索し、価格のみを検索します.
  • Input
    query {
      fetchProduct(productId: "f8f63f1b-39d1-477c-950f-8ce32a3bc8c4") {
        price
      }
    }
    Output
    {
      "data": {
        "fetchProduct": {
          "price": 1100
        }
      }
    }
    照会
  • の商品を削除してください.
  • Input
    mutation {
      deleteProduct(productId: "f8f63f1b-39d1-477c-950f-8ce32a3bc8c4") {
        message
      }
    }
    Output
    {
      "data": {
        "deleteProduct": {
          "message": "상품이 정상적으로 삭제되었습니다."
        }
      }
    }
  • 削除された商品が本当に削除されたかどうかをもう一度調べてください.
  • Input
    query {
      fetchProduct(productId: "f8f63f1b-39d1-477c-950f-8ce32a3bc8c4") {
        name
        detail
        price
      }
    }
    Output
    {
      "data": {
        "fetchProduct": null
      }
    }
  • 投稿リストで、2ページ目を参照してください.
  • Input
    query {
      fetchBoards(page: 2) {
        number
        writer
        title
        contents
      }
    }
    Output
    {
      "data": {
        "fetchBoards": [
          {
            "number": 17,
            "writer": "맹구",
            "title": "가끔은 눈물을 참을 수 없는 내가 별루 다.",
            "contents": "히히히힣히히"
          },
          {
            "number": 16,
            "writer": "hard",
            "title": "hard",
            "contents": "hard하드"
          },
          {
            "number": 15,
            "writer": "맹구",
            "title": "API",
            "contents": "API는 어렵다."
          },
          {
            "number": 14,
            "writer": "짱구",
            "title": "나는 왜",
            "contents": "졸린가,,,"
          },
          {
            "number": 13,
            "writer": "Chungsik",
            "title": "This is a title.",
            "contents": "This is a content."
          },
          {
            "number": 12,
            "writer": "shong",
            "title": "나는 왜",
            "contents": "졸린가,,,"
          },
          {
            "number": 11,
            "writer": "코캠",
            "title": "코캠파이팅",
            "contents": "하하"
          },
          {
            "number": 10,
            "writer": "영은",
            "title": "호두자두 사랑해",
            "contents": "호두자두 일상글"
          },
          {
            "number": 9,
            "writer": "스펀지밥",
            "title": "행복합니다.",
            "contents": "잉잉"
          },
          {
            "number": 8,
            "writer": "스타벅스",
            "title": "아메리카노",
            "contents": "조아조아"
          }
        ]
      }
    }
  • 投稿リストを参照するときにpageを入力しないと、どのような結果が得られますか?
  • Input
    query {
      fetchBoards {
        number
        writer
        title
        contents
      }
    }
    Output
    {
      "data": {
        "fetchBoards": [
          {
            "number": 71,
            "writer": "Chungsik",
            "title": "This is an edited title.",
            "contents": "These are modified contents."
          },
          {
            "number": 70,
            "writer": "Chungsik",
            "title": "This is a title.",
            "contents": "These are contents."
          },
          {
            "number": 69,
            "writer": "Chungsik",
            "title": "This is a title.",
            "contents": "These are contents."
          },
          {
            "number": 68,
            "writer": "Chungsik",
            "title": "This is a title.",
            "contents": "These are contents."
          },
          {
            "number": 67,
            "writer": "Chungsik",
            "title": "This is a title.",
            "contents": "These are contents."
          },
          {
            "number": 66,
            "writer": "Chungsik",
            "title": "This is a title.",
            "contents": "These are contents."
          },
          {
            "number": 65,
            "writer": "junku",
            "title": "노가다",
            "contents": "코드도 잘 모르겠다."
          },
          {
            "number": 64,
            "writer": "재훈",
            "title": "제목2",
            "contents": "수정"
          },
          {
            "number": 58,
            "writer": "철수",
            "title": "제목",
            "contents": "내용입니다"
          },
          {
            "number": 18,
            "writer": "유리",
            "title": "훈이사랑",
            "contents": "짱구도사랑"
          }
        ]
      }
    }
  • default値があります.出力結果は「page:1」と同じです.
  • 合計
  • プロファイルがいくつあるか見てみましょう.
  • Input
    query {
      fetchProfilesCount
    }
    Output
    {
      "data": {
        "fetchProfilesCount": 55
      }
    }
  • にはいくつの投稿がありますか?
  • Input
    query {
      fetchBoardsCount
    }
    Output
    {
      "data": {
        "fetchBoardsCount": 27
      }
    }