GraphQL
하니2026.01.18
loading ...
카카오 개발자 왈
GraphQL이란?
개념
차이
SELECT plot_id, species_id, age, weight, ROUND(weight / 1000.0, 2) FROM surveys;
{hero {namefriends {name}}}

모바일 앱에서 뉴스피드 화면 하나를 띄우는데:
→ REST로 하면 API를 5~7번 호출해야 했음
🚨문제
{"id": 1,"name": "재영","age" : 26,"email" : "cjy3458@naver.com",}
{"title": "뉴스 제목입니다",}{"author": "최기자",}{"comment": {"id": 1,"content"
“서버가 아니라 클라이언트가 데이터 구조를 정의하게 하자”
그래서 만든 게 GraphQL (2015 공개)
Rest API


GQL


GQL은 호출 한 번으로 원하는 데이터를 명확하게 가져올 수 있음
쿼리 / 뮤테이션 / 응답
// 쿼리문{camper {name}}// 응답{"data": {"camper" : {"name" : "Jay"
type Query {product(id: ID!): Product}type Mutation {addProduct(name: String!, price: Int!): Product
query GetProduct {product(id: "1") {nameprice}}
mutation AddProduct {addProduct(name: "맥북", price: 2000000) {idname}}