GraphQL and Microservices

Having come from a REST API centric view of the world, GraphQL is truly a game-changer with the ability to perform fine-grained queries that are well suited for multiple front end applications. By leveraging GraphQL stitching, we have built out a robust API strategy that is both consumable and scalable with the ability to add additional microservices in the future.


 GraphQL is extremely powerful, and that the benefits at hand are especially powerful for most microservice structures – though not all. In some cases, especially in cases in which the data does not change, new endpoints are not added, and additional functions are not required, GraphQL may add additional unwarranted complexity.GraphQL has often been sold as a perfect solution for every problem, but the reality is that it meets one requirement better than most others, and if that’s not part of your requirements, it may not be the best solution for your implementation.

GraphQL

GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015.
Major GraphQL clients include Apollo Client and Relay. GraphQL servers are available for multiple languages, including Haskell, JavaScript, Perl, Python, Ruby, Java, C#, Scala, Go, Elixir, Erlang, PHP, R, and Clojure.
A GraphQL service is created by defining types and fields on those types, then providing functions for each field on each type. For example, a GraphQL service that tells us who the logged-in user is (me) as well as that user's name might look something like this:

type Query {
  me: User
}

type User {
  id: ID
  name: String
}

Microservices 

Microservices are a software development technique—a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained and the protocols are lightweight.
  1. Easier to Build and Maintain Apps
  2. Organized Around Business Capabilities
  3. Improved Productivity and Speed
  4. Flexibility in Using Technologies and Scalability
  5. Autonomous, Cross-functional Teams
Microservices offer a unique kind of modularization; they make big solutions easier, increase productivity, offer flexibility in choosing technologies and are great for distributed teams. However, like any architectural approach, microservices have their disadvantages. Sometimes, using different languages, libraries, frameworks and data storage technologies can be intimidating and paralyzing for organizations. Plus, not every team can handle the autonomy and independence microservices offer. But if you have a large project, need quick and autonomous delivery, plan to scale your solution or need to frequently update separate parts of your system, microservices are your best bet.