Part1: Mesh Gateway 구성 파일 생성

송톰톰·2023년 1월 22일
0
post-thumbnail

GraphQL Mesh 를 통해 REST API, GraphQL, gRPC 등등 마이크로서비스 아키텍쳐(MSA) 인프라에서 GraphQL 게이트웨이를 구축 할 수 있습니다.

인프라 구성 목표

GraphQL Mesh 튜토리얼 예제를 목표로 하여 개발 합니다.

  • Books API (REST API)
    • GET /books
    • GET /books/:id
    • GET /categories
  • Authors API (gRPC API)
    • GetAuthor
    • ListAuthors
  • Stores (GraphQL API)
    • stores Query
    • bookSells(storeId: ID!) Query

Mesh CLI 설치

$ mkdir mesh_gateway
$ cd mesh_gateway
$ yarn add @graphql-mesh/cli graphql

.meshrc.yaml 정의

  • .meshrc.yaml
sources:
  - name: Books
    handler:
      openapi:
        endpoint: http://localhost:3002/
  - name: Authors
    handler:
      grpc:
        endpoint: http://localhost:3003/
  - name: Stores
    handler:
      graphql:
        endpoint: http://localhost:3004/
serve:
  hostname: 0.0.0.0
  port: 80
  endpoint: /
  browser: false
  playground: true

Mesh 시작, 빌드

{
  "scripts": {
    "start": "mesh start",
    "build": "mesh build"
  }
}

Books, Authors, Stores API endpoint 를 기본 설정하고 예제를 진행하면서 수정하겠습니다.

Reference

Github

0개의 댓글