GraphQL API
The GraphQL API is Dagster's typed boundary for reading orchestration state and requesting operational actions. It connects clients such as the Dagster UI to the workspace and Dagster instance through one request-scoped view. The webserver and workspace page explains how this boundary is hosted, while user interfaces places it beside the other user-facing surfaces.
API boundary
The API serves queries, mutations, and subscriptions from the same schema. Queries expose definitions and stored state. Mutations request changes to runs, automation, assets, and workspace state. Subscriptions stream new events for views that must stay current.
This diagram shows the main relationship between a client operation, its request context, and Dagster state.
flowchart LR
C[GraphQL client] --> E[GraphQL endpoint]
E --> S[Schema roots]
S --> R[Resolvers]
R --> W[Workspace snapshot]
R --> I[Dagster instance]
W --> O[Definitions and location state]
I --> P[Runs, events, logs, and controls]
O --> C
P --> C
The webserver exposes HTTP GraphQL at /graphql and uses the same path for the WebSocket subscription endpoint. A client can send a document with variables and an optional operation name. The server parses and validates the document before it runs any resolver; see the webserver and workspace page for the transport lifecycle.
Schema model
Root operations
The schema has three root operation types. Query reads the current deployment view. Mutation exposes controlled changes. Subscription provides streams for data that changes during an active operation. The schema also registers shared object, input, enum, union, and error types so clients can select a precise response shape.
The root fields group the product around these areas:
- Workspace and definitions: code locations, repositories, jobs, graphs, resources, schedules, sensors, and partitions.
- Execution state: runs, run groups, plans, configuration validation, events, and captured logs.
- Asset state: assets, materializations, asset checks, partitions, health, and automation evaluations.
- Deployment state: instance details, daemon and instigation state, permissions, backfills, and concurrency.
References: python_modules/…/__init__.py• L8-88 python_modules/…/query.py• L226-705 python_modules/…/mutation.py• L1221-1267 python_modules/…/subscription.py• L13-44
Typed selectors and results
Selectors identify objects in the workspace without making clients depend on an in-process object. A repository selector uses a code-location name and repository name. Job selectors can also carry operation, asset, and asset-check selections so a query or launch request can target part of a job.
Partition definitions have a typed view. The schema distinguishes static, time-window, dynamic, and multi-partitioned definitions. For a multi-partitioned definition, the response names each dimension and marks dynamic dimensions so clients can handle partition keys as part of the definition rather than as untyped display data. Partition-key ranges use an inclusive startIdx and an exclusive endIdx where the field supports bounds; static definitions still return all keys.
Many fields return an OrError union or another result union. This makes expected conditions such as a missing definition, an invalid subset, an unsupported action, or an authorization failure part of the typed response. A client must inspect the returned type rather than assume that a successful HTTP response means that the requested operation succeeded.
References: python_modules/…/inputs.py• L1-120 python_modules/…/errors.py• L9-32 python_modules/…/errors.py• L185-208 python_modules/…/partition_sets.py• L500-598 python_modules/…/utils.py• L608-625 python_modules/…/owners.py• L6-36 python_modules/…/snapshot.py• L18-41
Request context
Context construction
The GraphQL request context is a fixed view of the workspace for one request or WebSocket operation. It carries the Dagster instance, the workspace snapshot, code-location access, version data, permission state, and request-scoped loaders. This isolates a resolver from a location that the long-lived workspace process may reload or clean up at the same time.
The context path is:
- The webserver receives an HTTP request or WebSocket connection.
- The workspace process creates a request context from its current workspace.
- GraphQL executes the operation with that context as its value.
- Resolvers read definitions from the workspace snapshot and durable state from the instance.
- The context closes after the request or subscription operation ends.
References: python_modules/…/graphql.py• L56-89 python_modules/…/graphql.py• L251-265 python_modules/…/graphql.py• L330-345 python_modules/…/context.py• L122-161 python_modules/…/context.py• L777-875
Resolver layers
The root resolver layer maps GraphQL fields to domain operations. It converts GraphQL inputs into Dagster selectors and execution parameters, then calls fetch or action logic that knows how to read the workspace and instance. Nested schema types add related data such as run events, asset records, schedules, sensors, and partition keys without changing the root contract.
Resolvers can use request-scoped batch loading when several nested fields need related data from one repository. Fields that can represent large partition definitions defer their key read until partitionKeys is selected. Automation-condition labels also defer snapshot expansion until a label field is selected. This keeps definition-only requests small and lets bounded requests read only the requested partition range.
This diagram shows how a field moves from the public schema to the state systems.
flowchart LR
F[GraphQL field] --> Q[Root resolver]
Q --> N[Input and selector conversion]
N --> D[Domain fetch or action]
D --> W[Workspace definitions]
D --> I[Instance storage]
D --> T[Nested typed result]
T --> F
References: python_modules/…/query.py• L709-779 python_modules/…/query.py• L891-923 python_modules/…/mutation.py• L120-191 python_modules/…/loader.py• L24-55 python_modules/…/pipeline.py• L43-61 python_modules/…/partition_sets.py• L646-732 python_modules/…/automation_condition.py• L16-52
Query paths
Workspace and definition queries
Workspace queries give clients the names and status of the code locations that make definitions available. Repository and definition queries then expose jobs, graphs, resources, schedules, sensors, partition sets, and configuration schemas. The same selectors carry the request from a location to the definition that a client wants to inspect.
Partition-set queries expose both the partition definition and the operational view of its keys. Static and time-window keys come from the definition, while dynamic keys come from the instance's dynamic partition state. Multi-partitioned definitions expose their dimensions so a client can interpret the returned keys in the right scope. Partition-key fields load keys only when selected, and bounded time-window or dynamic requests use the requested index range.
These queries read two related sources. The workspace supplies the current definition view. The instance supplies durable operational state such as instigation state, ticks, runs, and materializations. A definition can therefore be available even when it has no run history, and a location load problem can be shown separately from an empty definition.
References: python_modules/…/query.py• L237-369 python_modules/…/query.py• L443-471 python_modules/…/partition_sets.py• L334-433 python_modules/…/partition_sets.py• L500-598 python_modules/…/partition_sets.py• L646-732 python_modules/…/external.py• L121-172 python_modules/…/external.py• L175-216 python_modules/…/snapshot.py• L18-41
Run and event queries
Run queries expose searchable run history and individual run detail. Clients can follow a run to its target job, status, tags, run group, asset effects, event logs, step statistics, and captured logs. Cursor and limit fields support long histories without requiring the API to return the full record set at once.
Run selections can be bounded for large asset and asset-check jobs while separate count fields preserve the full selection size. The runs feed also presents roots, individual runs, or partition backfills as a time-ordered view. Its cursor keeps the run and backfill sources aligned across pages.
The run status model includes SUSPENDED for a run that has started and is waiting on external work without a run worker. The API also exposes RunSuspendedEvent and RunResumedEvent in the run-event union, so clients can show the transition in the same typed event stream as other run state changes. Suspended runs remain part of in-progress views and use the started-run timing behavior rather than appearing as completed work.
Execution-plan and configuration queries sit before a run is launched. They let a client check configuration and see the planned work for a selected job and mode. The plan also reports selected assets and asset checks. This gives the UI or another tool a way to surface invalid input before it requests execution.
Run records and event pages use server-side limits when the caller does not provide a page size. An explicit limit above the configured default is clamped rather than rejected, so callers must use the returned cursor to continue through a large result set.
References: python_modules/…/query.py• L380-471 python_modules/…/query.py• L925-1088 python_modules/…/pipeline.py• L114-131 python_modules/…/pipeline.py• L567-677 python_modules/…/pipeline.py• L733-758 python_modules/…/pipeline.py• L878-899 python_modules/…/status.py• L5-43 python_modules/…/execution.py• L131-175 python_modules/…/fetch_runs.py• L115-179 python_modules/…/fetch_runs.py• L549-682 python_modules/…/utils.py• L742-753
Asset and automation queries
Asset queries connect asset definitions to materialization records, observations, checks, partitions, health, and automation evaluations. The asset list combines the current asset graph with materialized asset keys, so an asset can appear before it has a materialization. Together these paths let a client compare the desired asset graph with the durable evidence of what ran.
Asset checks expose their definition, execution status, latest evaluation, target materialization, and partition-aware status. Partitioned checks use a typed result shape for time-window, static or dynamic, and multi-partitioned definitions. Their status model distinguishes success, failure, in-progress, skipped, and execution-failed states. Their partition keys follow the same lazy and bounded loading rules as asset partition keys.
Instigation state gives schedules and sensors one common view. It reports whether the instigator runs, its type-specific data, related runs, the next expected tick, permission state, and historical ticks. Tick history supports status and time filters, cursors, and a bounded result size. The API can read a small unfiltered history through repository-scoped batching; filtered or cursor-based requests read tick summaries from instance storage and load full tick data only when a selected field needs it.
Asset freshness fields use the workspace-merged asset view. If several code locations define the same asset, a freshness policy declared by a lower-priority definition remains visible when higher-priority definitions do not declare one. The same merged policy also drives freshness status, so the API view and freshness evaluation use the same policy source.
Automation conditions describe the rule tree that guides asset or check decisions. The schema returns a compact object first and expands its label only when the client selects that field, which keeps broad asset queries from rebuilding every condition tree.
The API also exposes backfill records and previews. A preview describes the partitions that an action would target. A backfill query describes the state of the work after it has been requested.
References: python_modules/…/query.py• L473-547 python_modules/…/query.py• L597-673 python_modules/…/asset_checks.py• L62-100 python_modules/…/asset_checks.py• L158-273 python_modules/…/asset_checks.py• L277-468 python_modules/…/asset_graph.py• L265-380 python_modules/…/asset_graph.py• L912-977 python_modules/…/instigation.py• L238-400 python_modules/…/instigation.py• L625-840 python_modules/…/automation_condition.py• L22-52 python_modules/…/fetch_assets.py• L104-150 python_modules/…/fetch_assets.py• L432-603 python_modules/…/partition_status_utils.py• L25-256 python_modules/…/fetch_ticks.py• L19-84 python_modules/…/remote_asset_graph.py• L404-410 python_modules/…/backfill.py• L1-80
Mutation paths
Run control
Run mutations turn a selected job and execution input into a launch request. The path resolves a preset or supplied configuration, checks the job and any selected scope, then hands the request to the execution service. Re-execution uses either new execution parameters or a parent run and strategy.
Other run mutations terminate one or many runs or delete a stored run. Termination reports whether the requested run stopped successfully. Its policy can favor a safe stop or mark the run canceled at once, so callers must use the returned result to understand the outcome.
References: python_modules/…/mutation.py• L120-191 python_modules/…/mutation.py• L306-345 python_modules/…/mutation.py• L583-645 python_modules/…/mutation.py• L665-731 python_modules/…/utils.py• L608-677
Automation and workspace control
Schedule and sensor mutations change instigation state, reset state, set a sensor cursor, or run a dry evaluation. Workspace mutations reload the complete workspace or one code location, and can shut down a location when that operation is supported. These actions affect what later queries see because they change the active definition view or the state used to create runs.
The API also exposes controls for automatic materialization, dynamic partitions, concurrency limits, and app-managed component state. These controls share the same context and permission boundary even though they change different parts of deployment state.
References: python_modules/…/mutation.py• L719-853 python_modules/…/mutation.py• L1108-1203 python_modules/…/mutation.py• L1221-1267 python_modules/…/instigation.py• L402-567 python_modules/…/instigation.py• L625-750
Asset and backfill control
Backfill mutations create, resume, retry, or cancel work across selected partitions. Asset mutations can wipe stored asset history, report runless asset events, and report asset check results. The API returns a typed result so clients can distinguish a completed change from a missing asset, unsupported operation, or rejected request.
Dynamic partition mutations change the set of partition keys that later launches and backfills can select. Adding a key requires the selected repository to use the named dynamic partition definition and rejects an existing key. Deleting keys can also request removal of their asset materializations. For multi-partitioned assets, the API expands each deleted dimension key to the affected asset partitions before the wipe. It checks permissions, instance support, storage support, and a 100,000-asset-partition limit before changing the event log, so a failed pre-check leaves the partition keys and materializations unchanged.
References: python_modules/…/mutation.py• L378-520 python_modules/…/mutation.py• L856-1043 python_modules/…/dynamic_partitions.py• L23-71 python_modules/…/dynamic_partitions.py• L74-207 python_modules/…/dynamic_partitions.py• L246-321 python_modules/…/partition_sets.py• L60-94
Live data paths
Subscription streams
Subscriptions keep long-running views current. pipelineRunLogs streams events for one run. capturedLogs streams compute log data. locationStateChangeEvents tells clients when a code location changes state so they can refresh the workspace view.
Run event streams include suspended and resumed transitions as typed run events. A client can therefore distinguish a run that is waiting on external work from one that has finished, while retaining the same event connection and cursor model used for other run events.
The WebSocket server accepts the graphql-ws protocol. It acknowledges a connection, starts named subscription operations, sends data as results arrive, and cancels active work when the client stops an operation or disconnects. Point-in-time queries and polling remain useful for initial data and recovery after a connection loss.
References: python_modules/…/subscription.py• L13-53 python_modules/…/events.py• L99-143 python_modules/…/events.py• L651-699 python_modules/…/events.py• L347-375 python_modules/…/graphql.py• L176-232 python_modules/…/graphql.py• L330-362 python_modules/…/graphql.py• L403-445
Security and errors
Permission checks
The request context is the authority for deployment, code-location, owner, and asset-scope permissions. Read operations can remain available while a user lacks permission to change state. Mutations check the permission that matches the action before they launch work, alter definitions, edit assets, or change deployment controls.
Permission checks also record that a protected operation was checked. This prevents a mutation from silently gaining a new path that performs a state change without the required authorization decision.
References: python_modules/…/utils.py• L55-126 python_modules/…/utils.py• L129-199 python_modules/…/utils.py• L268-280 python_modules/…/context.py• L835-865 python_modules/…/asset_graph.py• L595-617 python_modules/…/instigation.py• L703-750
Error transport
The API uses two error levels. Expected domain failures are typed GraphQL results with a message and enough fields for a client to show the cause. Syntax, validation, and resolver failures are returned in the GraphQL errors list. Resolver failures can include serialized error information so an operator can trace a server-side problem.
An HTTP status does not replace the GraphQL result contract. Clients must handle both the response status and the data or errors content. A valid request can still contain a typed authorization or not-found result.
References: python_modules/…/errors.py• L9-80 python_modules/…/utils.py• L521-605 python_modules/…/graphql.py• L91-110 python_modules/…/graphql.py• L268-328 python_modules/…/graphql.py• L374-400 python_modules/…/snapshot.py• L33-41
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the GraphQL root fields, input selectors, result unions, and generated client schema aligned when a public operation changes.
- Preserve the request-context contract across HTTP queries, HTTP mutations, and WebSocket subscriptions. Each path must receive the workspace snapshot and instance access it needs.
- When a resolver changes how it maps a selector to a code location or repository, check nested fields and request-scoped batch loading for the same identity rules.
- Pair every new state-changing mutation with its deployment, location, owner, or asset permission check and its read-only behavior.
- When a mutation changes workspace or partition state, check the later query and subscription paths that must expose the new state.
- When instigation tick fields or filters change, keep the summary query, repository-scoped batch path, full tick loading, cursor and time bounds, result limit, and GraphQL tick fields aligned.
- When run statuses change, keep the status enum, run-feed classification, timing behavior, event union, event conversion, and generated client schema aligned. In particular, keep suspended runs in the in-progress view and expose both suspended and resumed events.
- When run or event query limits change, keep the server default, clamping rule, cursor behavior, and any explicit selection count fields aligned.
- When dynamic partition deletion can wipe materializations, keep the asset permission check, multi-partition expansion, instance and storage support checks, 100,000-partition limit, and no-partial-delete guarantee aligned.
- When asset definitions can be merged across code locations, keep GraphQL freshness fields aligned with the workspace asset policy selection and freshness evaluation path.
- When partition-key fields change, preserve lazy loading and the inclusive/exclusive range contract for time-window and dynamic definitions. Keep asset and asset-check fields aligned.
- When partition status fields change, keep the asset and asset-check status unions aligned with their status values and compressed time or multi-partition representations.
- When owner or snapshot types change, keep the definition-owner union, legacy asset-owner names, snapshot result union, and client
__typenamechecks compatible. - Keep typed domain failures distinct from transport or server errors so clients can branch on the result type without guessing from a message.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A client uses a selector for a missing or unloaded location | The query or mutation returns a typed not-found or location error instead of the requested definition or action | Query workspace status first and handle the OrError result types. |
| A mutation skips or loses its permission check | A state-changing operation can be rejected late or create an unsafe authorization gap | Use the context permission helpers and the protected mutation decorators. |
| A request uses a workspace object while that location is being reloaded | A resolver can read stale or invalid location resources | Create and use one fixed request context for the operation. |
| A client adds a dynamic partition key that already exists | The add operation returns a duplicate-partition result and does not add the key | Treat the typed duplicate error as an expected result. |
| A client requests a dynamic-partition wipe that expands beyond 100,000 asset partitions | The operation returns an unsupported-operation result and leaves partition keys and materializations unchanged | Delete fewer keys at a time or wipe materializations separately. |
| A client requests a dynamic-partition wipe for a multi-partitioned asset on an instance or event-log storage without support | The operation returns an unsupported-operation result and leaves partition keys and materializations unchanged | Check instance and storage support before requesting the combined delete. |
| A client treats HTTP 200 as operation success | A typed authorization, validation, or domain failure can be shown as a successful action | Inspect GraphQL result unions and the errors list as well as the HTTP status. |
| A client requests more run or event records than the server default | The API clamps the page instead of returning all requested records | Use the returned cursor and request later pages. |
| A tick cursor does not end in a valid timestamp | The API ignores the cursor bound and warns, so the client can receive an unexpected tick window | Treat cursors as opaque API values and use returned cursors for the next page. |
| A tick query requests too many records | The request is limited by the configured maximum instead of returning the full requested history | Page through results and keep the configured tick query limit in mind. |
A client treats SUSPENDED as a terminal run state | A run waiting on external work can disappear from in-progress views or show the wrong timing and action state | Use the RunStatus enum and its event stream. Handle RunSuspendedEvent and RunResumedEvent as lifecycle transitions. |
| A subscription disconnects during a run or location update | Live events stop and the client view becomes stale | Reconnect and use point-in-time queries or polling to recover the current state. |
| A schema field changes without matching client schema or generated types | The UI or another typed client can send invalid fields or read the wrong result shape | Update the server schema and generated client contract together. |
| A request selects partition-key fields for a very large dynamic definition without bounds | The API reads the selected key range, which can still be very large and slow | Use bounded startIdx and endIdx fields or a partition-key connection where available. |
| A caller assumes omitted partition-key fields still load the keys | A definition-only response does not include partition keys | Select partitionKeys when the keys are needed. |
| An asset freshness policy exists only in a lower-priority code location | A client can miss the policy and its freshness status even though the workspace defines one | Read the workspace-merged asset node rather than only the singular definition. |
| A client assumes all asset-check partition statuses use asset status names | The client cannot interpret the check result union or hides skipped and execution-failed partitions | Branch on the asset-check status union and handle every check status value. |
| A client assumes an owner or snapshot result has one concrete type | The client can fail to render ownership or treat a missing snapshot as a server error | Inspect __typename and handle the definition-owner and snapshot result unions. |
Key files
| File | Why to read it |
|---|---|
| python_modules/…/__init__.py | Shows how the query, mutation, subscription, and shared GraphQL types form one schema. |
| python_modules/…/query.py | Defines the read surface for workspace definitions, runs, assets, logs, automation, and instance state. |
| python_modules/…/mutation.py | Defines the control surface for execution, workspace, asset, automation, partition, and concurrency actions. |
| python_modules/…/subscription.py | Defines the live streams for run events, compute logs, and location state changes. |
| python_modules/…/execution.py | Defines the execution-plan view of steps, dependencies, selected assets, and selected asset checks. |
| python_modules/…/partition_sets.py | Defines partition-set queries, partition definition types, lazy and bounded partition-key reads, dynamic partition names, and partition result unions. |
| python_modules/…/asset_checks.py | Defines asset-check metadata, execution results, and partition-aware check status views. |
| python_modules/…/instigation.py | Defines schedule and sensor state, tick results, dry-run evaluations, dynamic partition requests, and permission fields. |
| python_modules/…/fetch_ticks.py | Defines tick history bounds, limits, batch reads, and lazy full-tick preparation. |
| python_modules/…/dynamic_partitions.py | Defines the checks, multi-partition expansion, safety limit, and state changes for adding or deleting dynamic partition keys. |
| python_modules/…/events.py | Maps stored Dagster events into the typed GraphQL event stream, including suspended and resumed run transitions. |
| python_modules/…/fetch_assets.py | Connects the current asset graph with materialized asset records and partition status. |
| python_modules/…/partition_status_utils.py | Provides the shared status representation for time and multi-partitioned asset views. |
| python_modules/…/fetch_runs.py | Provides run queries, server-side page limits, run-feed views, and suspended-run classification. |
| python_modules/…/utils.py | Shows the shared permission, error, selector, and query-limit rules used by resolvers. |
| python_modules/…/external.py | Shows how GraphQL resolves workspace locations, repositories, and remote jobs. |
| python_modules/…/loader.py | Shows how repository-scoped request data is batched for nested GraphQL fields. |
| python_modules/…/asset_graph.py | Defines the asset query surface, including merged freshness fields, automation conditions, partition state, dependencies, materialization history, and lazy partition-key fields. |
| python_modules/…/automation_condition.py | Defines the compact and lazy view of asset automation conditions. |
| python_modules/…/owners.py | Defines user and team owner unions and compatibility names for asset owners. |
| python_modules/…/events.py | Defines the typed event interfaces and union returned by run log queries and streams. |
| python_modules/…/pipeline.py | Defines run and job views, including status-dependent timing, bounded selections, owners, and event connections. |
| python_modules/…/status.py | Defines the public run status values and their client-facing meanings. |
| python_modules/…/snapshot.py | Defines the pipeline snapshot object and its not-found or Python-error result union. |
| python_modules/…/remote_asset_graph.py | Defines how asset definitions from several code locations are combined and how shared freshness policies are selected. |
| python_modules/…/context.py | Defines the process and request contexts that connect GraphQL to a stable workspace view. |
| python_modules/…/graphql.py | Defines GraphQL HTTP parsing, validation, execution, WebSocket subscriptions, and error responses. |
| python_modules/…/webserver.py | Shows where HTTP and WebSocket GraphQL routes enter the webserver. |
| js_modules/…/schema.graphql | Shows the browser-facing schema vocabulary used by the Dagster UI. |