When and How to use GraphQL with microservice architecture
<p>I'm trying to understand where GraphQL is most suitable to use within a microservice architecture.</p>
<p>There is some debate about having only 1 GraphQL schema that works as API Gateway proxying the request to the targeted microservices and coercing their response. Microservices still would use REST / Thrift protocol for communication though.</p>
<p>Another approach is instead to have multiple GraphQL schemas one per microservice. Having a smaller API Gateway server that route the request to the targeted microservice with all the information of the request + the GraphQL query.</p>
<p><strong>1st Approach</strong></p>
<p>Having 1 GraphQL Schema as an API Gateway will have a downside where every time you change your microservice contract input/output, we have to change the GraphQL Schema accordingly on the API Gateway Side.</p>
<p><strong>2nd Approach</strong></p>
<p>If using Multiple GraphQL Schema per microservices, make sense in a way because GraphQL enforces a schema definition, and the consumer will need to respect input/output given from the microservice.</p>
<p><strong>Questions</strong></p>
<ul>
<li><p>Where do you find GraphQL the right fit for designing microservice architecture?</p>
</li>
<li><p>How would you design an API Gateway with a possible GraphQL implementation?</p>
</li>
</ul>