Netflix has developed a Domain Graph Service (DGS) framework and it is now open source. The DGS framework simplifies the implementation of GraphQL, both for standalone and federated GraphQL services. Our framework is battle-hardened by our use at scale.
By open-sourcing the project, we hope to contribute to the Java and GraphQL communities and learn from and collaborate with everyone who will be using the framework to make it even better in the future.
The key features of the DGS Framework include:
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
Why We Needed a DGS Framework
Around Spring 2019, Netflix embarked on a great adventure towards implementing a federated GraphQL architecture. Our colleagues wrote a Netflix Tech Blog post describing the details of this architecture. The transition to the new federated architecture meant that many of our backend teams needed to adopt GraphQL in our Java ecosystem. As you may recall from a previous blog post, Netflix has standardized on Spring Boot for backend development. Therefore, to make this federated architecture a success, we needed to have a great developer experience for GraphQL in Spring Boot.
We created our framework on top of Spring Boot and it leverages the graphql-java library. This framework was initially intended to be internal only, focusing on integration with the Netflix ecosystem for tracing, logging, metrics, etc. However, proper modularization of the framework was always top of mind. 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.
Schema-First Development
A schema represents the GraphQL API. The schema is what makes GraphQL so powerful and different from REST. A GraphQL schema describes the API in terms of Query and Mutation operations along with their related types and fields. The API user can specify precisely which fields to retrieve in a query, making a GraphQL API very flexible.
There are two different approaches to GraphQL development; schema-first and code-first development. With schema-first development, you manually define your API’s schema using the GraphQL Schema Language. The code in your service only implements this schema.
With code-first development, you don’t have a schema file. Instead, the schema gets generated at runtime based on definitions in code.
Both approaches, schema-first and code-first, are supported in our framework. At Netflix we strongly prefer schema-first development because:
The schema design is front and center of the developer experience.
It provides an easy way for tooling to consume the schema.
Backward-incompatible changes are more obvious with schema diffs. Backward compatibility is even more critical when working in a Federated GraphQL architecture.
Although it might be marginally quicker to generate schema from the code, putting the time into designing your schema in a human readable, collaborative way is well worth the effort towards a better API.
The Framework in Action
The framework’s core revolves around the annotation-based programming model familiar to Spring Boot developers. Comprehensive documentation is available on the website but let’s walk through an example to show you how easy it is to use this framework.
https://digg.com/@adflyne-sfre
https://digg.com/@erte-sere
https://bigpicture.net/users/blackpink-show-online-watch-hd
https://bigpicture.net/users/demon-slayer-mugen-train-full-online-watch-hd-2020
https://bigpicture.net/users/monster-hunter-online-watch-hd
https://bigpicture.net/users/crood-new-age-online-watch-hd
https://bigpicture.net/users/wonder-woman-1984-online-watch-hd
https://bigpicture.net/users/watch-little-things-online-watch-hd
https://bigpicture.net/users/marksman-online-watch-hd
https://bigpicture.net/users/wanda-vision-season-1-episode-5-full-episodes
https://bigpicture.net/users/watch-re-zero-season-2-episode-18-full-episodes
https://bigpicture.net/users/watch-riverdale-season-5-episode-3-full-episodes
https://bigpicture.net/users/tenet-online-watch-hd
https://mundoalbiceleste.com/author/watch-blackpink-the-show-full-online/
https://mundoalbiceleste.com/author/watch-demon-slayer-mugen-train-2020-online-full-mo/
https://mundoalbiceleste.com/author/downloadmonsterhunterfullmoviefreeonline/
https://mundoalbiceleste.com/author/full-watch-monster-hunter-online/
https://mundoalbiceleste.com/author/watch-the-croods-a-new-age-2020-online-full-movie/
https://mundoalbiceleste.com/author/wonder-woman-1984-full-online/
https://mundoalbiceleste.com/author/the-little-things-2021-online-full-movie-hd/
https://mundoalbiceleste.com/author/the-marksman-full-movie/
https://mundoalbiceleste.com/author/watch-wandavision-season-1-episode-5-full-episodes/
https://mundoalbiceleste.com/author/re-zero-starting-life-in-another-world-online/
https://mundoalbiceleste.com/author/watch-riverdale-season-5-episode-3-full-episodes/
https://mundoalbiceleste.com/author/watch-tenet-2020-online-full-movie-hd/
https://adflyne.medium.com/open-sourcing-the-netflix-domain-graph-service-framework-graphql-for-spring-boot-f166d87f9877
https://www.guest-articles.com/news/open-sourcing-the-netflix-domain-graph-service-framework-graphql-for-spring-04-02-2021
http://veterinaren.nu/forum/katt/147114/1/open-sourcing-the-netflix-domain-graph-service-framework-graphql-for-spring-boot
http://www.clashofclans-tools.com/Thread-41786/open-sourcing-the-netflix-domain-graph-service-framework-graphql-for-spring-boot
https://avengger.cookpad-blog.jp/articles/568647
https://mlog.club/article/6196379
https://caribbeanfever.com/photo/albums/degrgre
http://sfbats.ning.com/photo/albums/dsgghrherhrehjr
http://network-marketing.ning.com/photo/albums/safdefgsergrehyreyhrt
http://www.onfeetnation.com/photo/albums/segrgreyherytuyrt
https://dcm.shivtr.com/forum_threads/3298593?post=14498871#forum_post_14498871
http://www.easymarks.org/link/188132/https-digg-com-adflyne-sfre
http://www.4mark.net/story/3168606/123movies-download-demon-slayer-mugen-train-full-hd-movie-online-digg
https://onlinegdb.com/nbx8NJHpb
https://www.posts123.com/post/1325623/123movies-download-demon-slayer-mugen-train-full-hd-movie-online-digg
https://paste.ee/p/rkMBN
https://paiza.io/projects/VFSsj4UGEXLEnhU6WzEcYw?language=php
http://paste.jp/0d45c3fe/
https://pasteio.com/xt8Q6yopfhsK
https://controlc.com/02210a7e
https://pastelink.net/2m1fj
https://slexy.org/view/s20zqNTgD2
https://www.hybrid-analysis.com/sample/e035b895592593edc9aa924429db7dae48e53638c731fe3140589e421c0aa282
https://urlscan.io/result/d6335f08-d0b0-4a28-9f07-e1b84a5075cd/
http://simplesitebooster.com/hosted/index.php
https://verify-www.com/index.php?url=https%3A%2F%2Fdigg.com%2F%40adflyne-sfre
https://www.peeranswer.com/question/601bb10de483247612825465
Let’s start with a simple schema.
The Show type is a simple POJO that we would typically generate using the DGS Code Generation plugin for Gradle. A method annotated with @DgsData implements a data fetcher for a field. Note that we don’t need data fetchers for each field, we can return Java objects, and the framework will take care of the rest.The framework also has many conveniences such as the @InputArgument annotation used in this example.
This code is enough to get a GraphQL endpoint running. Just start the Spring Boot application, and the /graphql endpoint will be available, along with the GraphiQL query editor on /graphiql that comes out of the box. Although the code in this example is straightforward, it wouldn’t look much different if we work with Federated types, use @Secured, or add metrics and tracing using an extension point. The framework takes care of all the heavy lifting.
Another key feature is support for lightweight query tests. These tests allow you to execute queries without the need to work with the HTTP endpoint. The tests look and feel like plain JUnit tests.
Full documentation for the framework is available on the DGS Framework github repository.
Fitting into the GraphQL Server Ecosystem
So how exactly does the DGS framework fit into the existing GraphQL ecosystem? The current ecosystem comprises servers, clients, the federated gateways, and tooling to help with query testing, schema management, code generation, etc. When it comes to building GraphQL servers using JVM, there are both schema-first and code-first libraries available.
A popular code-first library is graphql-kotlin for Kotlin. graphql-java is most popular for implementing schema-first GraphQL APIs in Java, but is designed to be a low level library. The graphql-java-kickstart starter is a set of libraries for implementing GraphQL services, and provides graphql-java-tools and graphql-java-servlet on top of graphql-java.
Regardless of whether you use Java or Kotlin, our framework provides an easy way to build GraphQL services in Spring Boot. It can be used to build a standalone service as well as in the context of Federated GraphQL.
Federation
The DGS Framework provides a convenient way to implement GraphQL services with federation. Federation allows services to share a unified graph exposed by a gateway. Typically, services share and extend types defined in the unified schema using the @extends directive as defined by Apollo’s federation specification. This is an effective way to split the ownership of a large monolithic GraphQL schema across microservices.
For an incoming query, the federated gateway constructs a query plan to call out to the required services to fulfill that query. Each service, in turn, needs to be able to respond to the _entities query in order to partially fulfill the query for the data it owns.
Given this schema, the Reviews DGS needs to implement a resolver for the federated Show type with the reviews field populated. This can be done easily using the @DgsEntityFetcher annotation as shown here:
The framework also makes it easy to test federated queries using code generation to generate the _entities query for the service based on the schema. The complete code for the given example can be found here.
Framework Architecture
From the early days of development, we focused on good modularization of the code. This was an important design choice that made it possible to open source most of the framework without impacting our internal teams. We couldn’t use the module system introduced in Java 9 yet, because a lot of applications at Netflix are still using Java 8. However, with the help of Gradle api and implementation modules, we were able to create a clean module structure. At Netflix, we have many extensions for Spring Boot to integrate with our infrastructure. We call this Spring Boot Netflix. The DGS framework is built on standard open-source Spring Boot. On top of that, we have some modules that integrate with our specific infrastructure and use only extension points provided by the core framework.
Distributed Tracing and Metrics
At Netflix, we have custom infrastructure for features like tracing, metrics, distributed logging, and authentication/authorization. As mentioned earlier, the DGS framework integrates with this infrastructure to provide a seamless experience out of the box. While these features are not open-sourced, they are easy enough to add to the framework.
The framework supports Instrumentation classes as defined in the graphql-java library. By implementing the Instrumentation interface and annotating it @Component, the framework is able to pick it up automatically. You can find some reference examples in our documentation. In the future, we are hopeful and excited to see community contributions around common patterns for distributed tracing and metrics.
Try It Out Today
To get started with the DGS Framework, refer to our documentation and tutorials. To contribute to the DGS framework, please check out the DGS Framework project on GitHub. We also have a Gradle code generation plugin for generating Java and Kotlin types from a GraphQL schema. To contribute to the code generation plugin, please check out the project on GitHub.
A Team Effort
The DGS Framework has been a success at Netflix owing to the efforts of multiple teams coming together. We would like to acknowledge our close collaborators from the BFG team with whom we started on this amazing journey. We would also like to thank our many users for their timely feedback and code contributions.
If you are passionate about GraphQL and building great developer experiences then check out the many job opportunities on our Netflix website.