# netflix/dgs-framework architecture

> Architecture diagram of the GitHub repository netflix/dgs-framework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/netflix/dgs-framework
- Repository: https://github.com/netflix/dgs-framework

## Overview

#### Purpose and Build
This is Netflix’s DGS Framework: a modular GraphQL server framework for Spring Boot, with client, test, observability, scalar/validation, pagination, and protocol libraries. Gradle is the repository entry point: `settings.gradle.kts`, `build.gradle.kts`, and per-module `build.gradle.kts`. Core runtime code is Java/Kotlin; Spring Boot provides application lifecycle and web transports.

#### Core DGS Programming Model
`graphql-dgs` defines the public annotation- and interface-based API used by application code: queries, mutations, subscriptions, data fetchers, scalars, directives, federation entities, and DataLoaders. Primary contracts include `graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsQuery.java`, `graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsData.java`, and `graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsDataLoader.java`.

#### Schema-to-Execution Assembly
At startup, DGS discovers schema resources and Spring-managed annotated components, converts annotated methods into GraphQL Java data fetchers, builds runtime wiring/code registry, then produces the executable GraphQL source. Key assembly boundaries are `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt`, `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/method/MethodDataFetcherFactory.kt`, and `graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/DgsGraphQLSourceBuilder.kt`.

#### Spring GraphQL Integration and Request Flow
`graphql-dgs-spring-graphql` is the Spring Boot integration layer. Its auto-configuration registers DGS behavior into Spring GraphQL, supports schema/data-loader reload, request context propagation, exception handling, and optional persisted queries. Request flow is HTTP/WebFlux transport → Spring GraphQL interceptor → DGS context/data fetcher execution → GraphQL response. Main entry points are `graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.kt`, `graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt`, and `graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webflux/DgsWebFluxGraphQLInterceptor.kt`.

#### Execution, Context, and Batching
The core executor supports programmatic query execution and test-facing execution. It creates request-scoped GraphQL/DGS context, maps GraphQL inputs to Java/Kotlin method parameters, invokes fetchers, and processes synchronous, future, coroutine, and reactive results. DataLoaders batch and cache field resolution per request. Relevant paths: `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/BaseDgsQueryExecutor.kt`, `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/context/GraphQLContextContributorInstrumentation.kt`, and `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DefaultDgsDataLoaderProvider.kt`.

#### Extensions and Observability
Optional Spring Boot modules add framework-level behavior without coupling the core: extended scalars, Bean Validation, pagination schema definitions, APQ caching, and Micrometer/Spectator metrics. Auto-configuration resource registration is the integration boundary. Key paths: `graphql-dgs-extended-scalars/src/main/kotlin/com/netflix/graphql/dgs/autoconfig/DgsExtendedScalarsAutoConfiguration.kt`, `graphql-dgs-pagination/src/main/kotlin/com/netflix/graphql/dgs/pagination/DgsPaginationAutoConfiguration.kt`, and `graphql-dgs-spring-boot-micrometer/src/main/kotlin/com/netflix/graphql/dgs/metrics/micrometer/DgsGraphQLMicrometerAutoConfiguration.kt`.

#### Client, Reactive, and Protocol Libraries
The separate client module executes GraphQL over custom executors, Spring `RestClient`, WebClient, WebSocket, and GraphQL-over-SSE; it maps transport responses through Jackson adapters. Reactive server support bridges DGS context and execution into reactive streams. Subscription protocol types are independently reusable. See `graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphQLClients.kt`, `graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/WebSocketGraphQLClient.kt`, and `graphql-dgs-reactive/src/main/java/com/netflix/graphql/dgs/reactive/DgsReactiveQueryExecutor.java`.

#### Published Consumption and Examples
Starter/platform modules package dependency sets for Spring Boot consumers, while examples demonstrate servlet, WebFlux, and Jackson compatibility variants rather than forming production runtime dependencies. Representative application entry points are `graphql-dgs-spring-graphql-example-java/src/main/java/com/netflix/graphql/dgs/example/SpringGraphQLExampleApp.java` and `graphql-dgs-spring-graphql-example-java-webflux/src/main/java/com/netflix/graphql/dgs/example/reactive/ReactiveSpringGraphQLExampleApp.java`.

Main entry points: [`graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.kt`](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.kt) (Spring auto-configuration), [`graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/BaseDgsQueryExecutor.kt`](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/BaseDgsQueryExecutor.kt) (DGS query executor), [`graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsData.java`](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsData.java) (DGS public API), [`graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/DgsGraphQLSourceBuilder.kt`](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/DgsGraphQLSourceBuilder.kt) (GraphQL source builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core runtime"]
  node_dgs_api["DGS public API<br/>annotation contracts<br/>[DgsData.java]"]
  node_dgs_query["Query contract<br/>annotation<br/>[DgsQuery.java]"]
  node_dataloader_api["DataLoader contract<br/>interface<br/>[DgsDataLoader.java]"]
  node_schema_provider["Schema provider<br/>startup assembly"]
  node_fetcher_factory["Fetcher factory<br/>method adapter"]
  node_query_executor["DGS query executor<br/>execution engine"]
  node_context_instrumentation["Context instrumentation<br/>request context"]
  node_dataloader_provider["DataLoader provider<br/>batching runtime"]
end

subgraph group_spring["Spring GraphQL"]
  node_spring_autoconfig["Spring auto-configuration<br/>Boot integration"]
  node_graphql_source["GraphQL source builder<br/>runtime source builder"]
  node_http_interceptors["HTTP/WebFlux interceptors<br/>request boundary"]
end

subgraph group_extensions["Optional extensions"]
  node_extended_scalars["Extended scalars<br/>Boot extension"]
  node_pagination["Pagination<br/>Boot extension"]
  node_micrometer["Micrometer metrics<br/>observability extension"]
end

subgraph group_client["Client and reactive"]
  node_graphql_clients["GraphQL clients<br/>transport client library<br/>[GraphQLClients.kt]"]
  node_websocket_client["WebSocket client<br/>subscription transport"]
  node_reactive_executor["Reactive query executor<br/>reactive bridge"]
end

subgraph group_consumption["Consumption"]
  node_servlet_example["Servlet example app<br/>example application"]
  node_webflux_example["WebFlux example app<br/>example application"]
end

node_gradle{{"Gradle build<br/>build entry point"}}

node_gradle -->|"builds"| node_dgs_api
node_gradle -->|"builds"| node_spring_autoconfig
node_gradle -->|"builds"| node_graphql_clients
node_dgs_query -->|"part of"| node_dgs_api
node_dataloader_api -->|"part of"| node_dgs_api
node_dgs_api -->|"annotated components"| node_schema_provider
node_schema_provider -->|"creates fetchers"| node_fetcher_factory
node_fetcher_factory -->|"runtime wiring"| node_graphql_source
node_schema_provider -->|"schema and registry"| node_graphql_source
node_spring_autoconfig -->|"registers"| node_graphql_source
node_http_interceptors -->|"propagates request context"| node_context_instrumentation
node_http_interceptors -->|"dispatches execution"| node_query_executor
node_graphql_source -->|"executes GraphQL"| node_query_executor
node_context_instrumentation -->|"supplies context"| node_query_executor
node_query_executor -->|"uses per request"| node_dataloader_provider
node_extended_scalars -.->|"extends"| node_spring_autoconfig
node_pagination -.->|"extends"| node_spring_autoconfig
node_micrometer -.->|"instruments"| node_spring_autoconfig
node_websocket_client -->|"transport implementation"| node_graphql_clients
node_reactive_executor -->|"reactive execution bridge"| node_query_executor
node_servlet_example -.->|"demonstrates"| node_spring_autoconfig
node_webflux_example -.->|"demonstrates WebFlux"| node_http_interceptors

click node_gradle "https://github.com/netflix/dgs-framework/blob/master/settings.gradle.kts"
click node_dgs_api "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsData.java"
click node_dgs_query "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsQuery.java"
click node_dataloader_api "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsDataLoader.java"
click node_schema_provider "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt"
click node_fetcher_factory "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/method/MethodDataFetcherFactory.kt"
click node_query_executor "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/BaseDgsQueryExecutor.kt"
click node_context_instrumentation "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/context/GraphQLContextContributorInstrumentation.kt"
click node_dataloader_provider "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DefaultDgsDataLoaderProvider.kt"
click node_spring_autoconfig "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.kt"
click node_graphql_source "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/DgsGraphQLSourceBuilder.kt"
click node_http_interceptors "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt"
click node_extended_scalars "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-extended-scalars/src/main/kotlin/com/netflix/graphql/dgs/autoconfig/DgsExtendedScalarsAutoConfiguration.kt"
click node_pagination "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-pagination/src/main/kotlin/com/netflix/graphql/dgs/pagination/DgsPaginationAutoConfiguration.kt"
click node_micrometer "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-boot-micrometer/src/main/kotlin/com/netflix/graphql/dgs/metrics/micrometer/DgsGraphQLMicrometerAutoConfiguration.kt"
click node_graphql_clients "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphQLClients.kt"
click node_websocket_client "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/WebSocketGraphQLClient.kt"
click node_reactive_executor "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-reactive/src/main/java/com/netflix/graphql/dgs/reactive/DgsReactiveQueryExecutor.java"
click node_servlet_example "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql-example-java/src/main/java/com/netflix/graphql/dgs/example/SpringGraphQLExampleApp.java"
click node_webflux_example "https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql-example-java-webflux/src/main/java/com/netflix/graphql/dgs/example/reactive/ReactiveSpringGraphQLExampleApp.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dgs_api,node_dgs_query,node_dataloader_api,node_schema_provider,node_fetcher_factory,node_query_executor,node_context_instrumentation,node_dataloader_provider toneBlue
class node_spring_autoconfig,node_graphql_source,node_http_interceptors toneAmber
class node_extended_scalars,node_pagination,node_micrometer toneMint
class node_graphql_clients,node_websocket_client,node_reactive_executor toneRose
class node_servlet_example,node_webflux_example toneIndigo
class node_gradle toneNeutral
```

## Components

### Core runtime

DGS API, schema assembly, and execution.

- [DGS public API](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsData.java): annotation contracts · Application-facing queries, data fetchers, and DataLoader contracts. · `graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsData.java`
- [Query contract](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsQuery.java): annotation · `graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsQuery.java`
- [DataLoader contract](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsDataLoader.java): interface · `graphql-dgs/src/main/java/com/netflix/graphql/dgs/DgsDataLoader.java`
- [Schema provider](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt): startup assembly · Discovers schemas and annotated Spring components. · `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt`
- [Fetcher factory](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/method/MethodDataFetcherFactory.kt): method adapter · Converts annotated methods into GraphQL Java fetchers. · `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/method/MethodDataFetcherFactory.kt`
- [DGS query executor](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/BaseDgsQueryExecutor.kt): execution engine · Maps inputs, invokes fetchers, and handles async or reactive results. · `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/BaseDgsQueryExecutor.kt`
- [Context instrumentation](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/context/GraphQLContextContributorInstrumentation.kt): request context · Creates and contributes request-scoped GraphQL/DGS context. · `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/context/GraphQLContextContributorInstrumentation.kt`
- [DataLoader provider](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DefaultDgsDataLoaderProvider.kt): batching runtime · Provides per-request batch and cache behavior. · `graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DefaultDgsDataLoaderProvider.kt`

### Spring GraphQL

Spring Boot integration and request transport.

- [Spring auto-configuration](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.kt): Boot integration · Registers DGS behavior, reload, exceptions, and optional persisted queries. · `graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.kt`
- [GraphQL source builder](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/DgsGraphQLSourceBuilder.kt): runtime source builder · Produces the executable GraphQL source for Spring GraphQL. · `graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/DgsGraphQLSourceBuilder.kt`
- [HTTP/WebFlux interceptors](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt): request boundary · Propagates request context into Spring GraphQL execution. · `graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/webmvc/DgsWebMvcGraphQLInterceptor.kt`

### Optional extensions

Auto-configured framework capabilities.

- [Extended scalars](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-extended-scalars/src/main/kotlin/com/netflix/graphql/dgs/autoconfig/DgsExtendedScalarsAutoConfiguration.kt): Boot extension · `graphql-dgs-extended-scalars/src/main/kotlin/com/netflix/graphql/dgs/autoconfig/DgsExtendedScalarsAutoConfiguration.kt`
- [Pagination](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-pagination/src/main/kotlin/com/netflix/graphql/dgs/pagination/DgsPaginationAutoConfiguration.kt): Boot extension · Adds pagination schema definitions. · `graphql-dgs-pagination/src/main/kotlin/com/netflix/graphql/dgs/pagination/DgsPaginationAutoConfiguration.kt`
- [Micrometer metrics](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-boot-micrometer/src/main/kotlin/com/netflix/graphql/dgs/metrics/micrometer/DgsGraphQLMicrometerAutoConfiguration.kt): observability extension · `graphql-dgs-spring-boot-micrometer/src/main/kotlin/com/netflix/graphql/dgs/metrics/micrometer/DgsGraphQLMicrometerAutoConfiguration.kt`

### Client and reactive

Reusable client, reactive, and protocol support.

- [GraphQL clients](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphQLClients.kt): transport client library · Executes through custom, HTTP, WebSocket, and SSE transports. · `graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphQLClients.kt`
- [WebSocket client](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/WebSocketGraphQLClient.kt): subscription transport · `graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/WebSocketGraphQLClient.kt`
- [Reactive query executor](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-reactive/src/main/java/com/netflix/graphql/dgs/reactive/DgsReactiveQueryExecutor.java): reactive bridge · Bridges DGS context and execution into reactive streams. · `graphql-dgs-reactive/src/main/java/com/netflix/graphql/dgs/reactive/DgsReactiveQueryExecutor.java`

### Consumption

Published dependency bundles and examples.

- [Servlet example app](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql-example-java/src/main/java/com/netflix/graphql/dgs/example/SpringGraphQLExampleApp.java): example application · `graphql-dgs-spring-graphql-example-java/src/main/java/com/netflix/graphql/dgs/example/SpringGraphQLExampleApp.java`
- [WebFlux example app](https://github.com/netflix/dgs-framework/blob/master/graphql-dgs-spring-graphql-example-java-webflux/src/main/java/com/netflix/graphql/dgs/example/reactive/ReactiveSpringGraphQLExampleApp.java): example application · `graphql-dgs-spring-graphql-example-java-webflux/src/main/java/com/netflix/graphql/dgs/example/reactive/ReactiveSpringGraphQLExampleApp.java`

### Other components

- [Gradle build](https://github.com/netflix/dgs-framework/blob/master/settings.gradle.kts): build entry point · Coordinates modular publishing and per-module builds. · `settings.gradle.kts`

## Connections

- Gradle build → DGS public API: builds
- Gradle build → Spring auto-configuration: builds
- Gradle build → GraphQL clients: builds
- Query contract → DGS public API: part of
- DataLoader contract → DGS public API: part of
- DGS public API → Schema provider: annotated components
- Schema provider → Fetcher factory: creates fetchers
- Fetcher factory → GraphQL source builder: runtime wiring
- Schema provider → GraphQL source builder: schema and registry
- Spring auto-configuration → GraphQL source builder: registers
- HTTP/WebFlux interceptors → Context instrumentation: propagates request context
- HTTP/WebFlux interceptors → DGS query executor: dispatches execution
- GraphQL source builder → DGS query executor: executes GraphQL
- Context instrumentation → DGS query executor: supplies context
- DGS query executor → DataLoader provider: uses per request
- Extended scalars → Spring auto-configuration: extends
- Pagination → Spring auto-configuration: extends
- Micrometer metrics → Spring auto-configuration: instruments
- WebSocket client → GraphQL clients: transport implementation
- Reactive query executor → DGS query executor: reactive execution bridge
- Servlet example app → Spring auto-configuration: demonstrates
- WebFlux example app → HTTP/WebFlux interceptors: demonstrates WebFlux
