Skip to content

Commit

Permalink
feat(core): expose graph json type (#27496)
Browse files Browse the repository at this point in the history
Closes #3283

## Current Behavior
See #3283

## Expected Behavior
See #3283

## Related Issue(s)
#3283

Fixes #
-  expose graph json type

---------

Co-authored-by: @NgDaddy Paweł Twardziak <contact@ngdaddy.com>
Co-authored-by: FrozenPandaz <jasonjean1993@gmail.com>
(cherry picked from commit 2c0a50c)
  • Loading branch information
Paweł Twardziak authored and FrozenPandaz committed Aug 24, 2024
1 parent be620eb commit f81b906
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
35 changes: 35 additions & 0 deletions docs/generated/devkit/GraphJson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Interface: GraphJson

The data type that `nx graph --file graph.json` or `nx build --graph graph.json` contains

## Table of contents

### Properties

- [graph](../../devkit/documents/GraphJson#graph): ProjectGraph
- [taskPlans](../../devkit/documents/GraphJson#taskplans): Record<string, string[]>
- [tasks](../../devkit/documents/GraphJson#tasks): TaskGraph

## Properties

### graph

**graph**: [`ProjectGraph`](../../devkit/documents/ProjectGraph)

The project graph

---

### taskPlans

`Optional` **taskPlans**: `Record`\<`string`, `string`[]\>

The plans for hashing a task in the task graph

---

### tasks

`Optional` **tasks**: [`TaskGraph`](../../devkit/documents/TaskGraph)

A graph of tasks populated with `nx build --graph`
1 change: 1 addition & 0 deletions docs/generated/devkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ It only uses language primitives and immutable objects
- [FileData](../../devkit/documents/FileData)
- [FileMap](../../devkit/documents/FileMap)
- [GeneratorsJson](../../devkit/documents/GeneratorsJson)
- [GraphJson](../../devkit/documents/GraphJson)
- [Hash](../../devkit/documents/Hash)
- [HasherContext](../../devkit/documents/HasherContext)
- [ImplicitJsonSubsetDependency](../../devkit/documents/ImplicitJsonSubsetDependency)
Expand Down
1 change: 1 addition & 0 deletions docs/generated/packages/devkit/documents/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ It only uses language primitives and immutable objects
- [FileData](../../devkit/documents/FileData)
- [FileMap](../../devkit/documents/FileMap)
- [GeneratorsJson](../../devkit/documents/GeneratorsJson)
- [GraphJson](../../devkit/documents/GraphJson)
- [Hash](../../devkit/documents/Hash)
- [HasherContext](../../devkit/documents/HasherContext)
- [ImplicitJsonSubsetDependency](../../devkit/documents/ImplicitJsonSubsetDependency)
Expand Down
18 changes: 15 additions & 3 deletions packages/nx/src/command-line/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,9 +1155,21 @@ function expandInputs(
};
}

interface GraphJsonResponse {
/**
* The data type that `nx graph --file graph.json` or `nx build --graph graph.json` contains
*/
export interface GraphJson {
/**
* A graph of tasks populated with `nx build --graph`
*/
tasks?: TaskGraph;
/**
* The plans for hashing a task in the task graph
*/
taskPlans?: Record<string, string[]>;
/**
* The project graph
*/
graph: ProjectGraph;
}

Expand All @@ -1166,8 +1178,8 @@ async function createJsonOutput(
rawGraph: ProjectGraph,
projects: string[],
targets?: string[]
): Promise<GraphJsonResponse> {
const response: GraphJsonResponse = {
): Promise<GraphJson> {
const response: GraphJson = {
graph: prunedGraph,
};

Expand Down
2 changes: 2 additions & 0 deletions packages/nx/src/devkit-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export type {
ProjectGraphProcessorContext,
} from './config/project-graph';

export type { GraphJson } from './command-line/graph/graph';

/**
* @category Project Graph
*/
Expand Down

0 comments on commit f81b906

Please sign in to comment.