---
title: Task graph
---

import TaskGraph from '@site/src/components/Docs/TaskGraph';

The task graph is a representation of all configured
[tasks in the workspace](../config/workspace#projects) and their relationships between each other,
and is represented internally as a directed acyclic graph (DAG). This graph is derived from
information in the [project graph](./project-graph). Below is a visual representation of a task
graph.

<TaskGraph />

:::info

The [`moon task-graph`](../commands/task-graph) command can be used to view the structure of your
workspace.

:::

## Relationships

A relationship is between a dependent (downstream task) and a dependency/requirement (upstream
task). Relationships are derived explicitly with the task [`deps`](../config/project#deps) setting,
and fall into 1 of 2 categories:

### Required

These are dependencies that are required to run and complete with a success, before the owning task
can run. If a required dependency fails, then the owning task will abort.

### Optional

The opposite of [required](#required), these are dependencies that can either a) not exist during
task inheritance, or b) run and fail without aborting the owning task.

## What is the graph used for?

Great question, the task graph is extremely important for running tasks (duh), and it also:

- Is fed into the [action graph](./action-graph) that can be executed in topological order.
- Determines affected tasks in [continuous integration](../guides/ci) workflows.
