When and How to use GraphQL with Microservice Architecture

前端 未结 9 1043
遇见更好的自我
遇见更好的自我 2021-01-29 17:13

I\'m trying to understand where GraphQL is most suitable to use within a Microservice architecture.

There is some debate about having only 1 GraphQL schema that works as

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-29 17:55

    As of 2019 the best way is to write microservises that implements apollo gateway specification and then glue together these services using a gateway following approach #1. The fastest way to build the gateway is a docker image like this one Then use docker-compose to start all the services concurrently:

    version: '3'
    
    services:
        service1:
            build: service1
        service2:
            build: service2
        gateway:
            ports:
                - 80:80
            image: xmorse/apollo-federation-gateway
            environment: 
                - CACHE_MAX_AGE=5
                - "FORWARD_HEADERS=Authorization, X-Custom-Header" # default is Authorization, pass '' to reset
                - URL_0=http://service1
                - URL_1=http://service2
    

提交回复
热议问题