Rest-API vs GraphQL-API

효딩딩·2022년 8월 1일
0

HTTP 통신이란?

  • HTTP는 Hyper Text Transfer Protocol 의 약자로써 인터넷에서 데이터를 주고받는 프로토콜을 말한다. 쉽게 말해서 두 컴퓨터간에 텍스트 데이터를 주고 받는 길 이라고 생각하면 된다.
  • HTTP 라는 길로 요청(request) 와 응답(response) 2가지를 주고받을수 있다

API 란?

  • HTTP 요청을 Backend 컴퓨터에 보냈을때 실행되는 Backend 기능이다
  • 쉽게 말해 API는 백엔드 개발자가 만든 함수이다
  • API에 요청(request)할 때 보내는 데이터는 API 함수로 들어갈 인자,
    응답(response)으로 받게 되는 데이터가 API 함수의 return 데이터이다

API의 종류: Rest-API 와 Graphql-API

  1. Rest-API
    - Rest (Respresentational State Transfer) 의 약자
    - Rest-API는 현재 가장 널리 사용되고있는 API이고
    응답 결과로 백엔드 개발자가 만든 함수에서 보내주는 모든 데이터를 받는다
    - axios를 통하여 Rest-API에 요청을한다
  1. graphQL이란?

    • GraphQL은 Facebook이 만든 API에 대한 쿼리 언어이다.
    • REST API 의 단점을 보완 (가령, 여러번 URL을 호출해서 가저와야하는 점) 하여 한번의 요청으로 필요한 데이터만 가져올수 있음.


(영문 해석)

The core difference between GraphQL and REST APIs is that GraphQL is a specification, a query language, while REST is an architectural concept for network-based software.

What is a REST API?

  • REST (Representational State Transfer) is an architectural style that conforms to a set of constraints when developing web services. It was introduced as a successor to SOAP APIs.
  • REST, or RESTful APs, are Web Service APIs that follow the REST standards. Unlike SOAP, a REST API is not constrained to an XML format and can return multiple data formats depending on what is needed. The data formats supported by REST API include JSON, XML, and YAML.

When a client calls REST APIs the server transfers the resources in a standardized representation. They work by returning information about the source that was requested - and is translated into an interpretable format.

What is GraphQL?

  • GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.
  • Maintained and developed primarily via the GraphQL Foundation, GraphQL has had incredible adoption across a variety of verticals and use cases with organizations like Twitter, Expedia, Shopify, and Hygraph to name a few.

Source:
https://www.guru99.com/graphql-vs-rest-apis.html
https://www.howtographql.com/basics/1-graphql-is-the-better-rest/
https://hygraph.com/blog/graphql-vs-rest-apis

profile
어제보다 나은 나의 코딩지식

0개의 댓글