Netflix has open sourced its “battle-hardened” Domain Graph Service (DGS) framework: a Spring Boot-based tool that has been designed to simplify the implementation of GraphQL — the query language for APIs.
That’s a lot of tooling jargon to squeeze into one paragraph, but Netflix’s OSS releases typically deserve watching closely: the company has been an innovation engine that has developed a fluid, cloud-native microservices architecture with much to admire about it — and the DGS Framework may be useful to those with similar estates.
The open source release comes as Netflix has grappled with some pain stemming from the fragmentation of data and relationships across myriad microservices. The DGS framework is part of its home-grown solution to the challenge of managing this complex architecture. At heart, the release represents an easier way to build GraphQL services, both standalone and federated. (GraphQL is a syntax that describes how to ask for data, and is generally used to load data from a server to a client. It was first developed at Facebook in 2012 as a way to rethink mobile app data-fetching from the perspective of product designers and developers and is widely used).
Netflix Domain Graph Service
As Netflix explained in a November 2020 blog, rather than exposing hundreds of microservices to UI developers, its own architecture is now designed to offer a unified API aggregation layer at the edge, letting developers work with “one conceptual API for a large domain.” But this approach has come with issues…
As the company notes: “Back-end developers love the decoupling and resilience offered by the API layer. But as we’ve… increased our domain complexity, developing the API aggregation layer has become increasingly harder.” (Many teams have been building duplicative data-fetching code and aggregation layers to support their product needs, the company admitted in November, in a tacit admission that things were getting messy, while others were having to manually add elements from the back-end into the graph API; a clunky process at odds with what microservices are meant to achieve: flexibility, scalability, and high levels of automation).
The DGS Framework is designed to tackle that issue, via the use of a federated GraphQL platform to power the unified API layer. Although the framework was initially intended to be internal only and used for tracing, logging, metrics, etc. “proper modularization of the framework was always top of mind”, the company says, adding that “it became apparent that much of the framework we had built was not actually Netflix specific. The framework was mostly just an easier way to build GraphQL services, both standalone and federated.”
The framework (built on standard open-source Spring Boot) pivots around GraphQL schema that lets the API user specify precisely which fields to retrieve in a query, and is designed to be an “effective way to split the ownership of a large monolithic GraphQL schema across microservices.” Netflix describes its key features as being:
- Annotation-based Spring Boot programming model
- Test framework for writing query tests as unit tests
- Gradle Code Generation plugin to create Java/Kotlin types from a GraphQL schema
- Easy integration with GraphQL Federation
- Integration with Spring Security
- GraphQL subscriptions (WebSockets and SSE)
- File uploads
- Error handling
- Automatic support for interface/union types
- A GraphQL client for Java
- Pluggable instrumentation
The curious can see documentation on GitHub here.