Skip to content

Commit de89e50

Browse files
authored
upgrade ts-graphviz to v1 (#2395)
1 parent ffa6c8f commit de89e50

4 files changed

Lines changed: 28 additions & 16 deletions

File tree

.changeset/selfish-files-raise.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@apollo/query-graphs": patch
3+
---
4+
5+
Update ts-graphviz dependency
6+

package-lock.json

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

query-graphs-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@apollo/federation-internals": "2.3.2",
2727
"@types/uuid": "^8.3.4",
2828
"deep-equal": "^2.0.5",
29-
"ts-graphviz": "^0.16.0",
29+
"ts-graphviz": "^1.5.4",
3030
"uuid": "^9.0.0"
3131
},
3232
"publishConfig": {

query-graphs-js/src/graphviz.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Functions used to output query graphs as [graphviz dot](https://graphviz.org/doc/info/lang.html) outputs. */
22

33
import { simpleTraversal, Edge, QueryGraph, QueryGraphState, Vertex } from "./querygraph";
4-
import { attribute, Digraph, digraph, ICluster, IEdge, INode, toDot as graphvizToDot } from 'ts-graphviz';
4+
import { attribute, digraph, RootGraphModel, GraphBaseModel, EdgeModel, NodeModel, toDot as graphvizToDot } from 'ts-graphviz';
55
import { RootPath, traversePath } from "./graphPath";
66

7-
function setDefaultGraphAttributes(_: Digraph) {
7+
function setDefaultGraphAttributes(_: RootGraphModel) {
88
//vizGraph.attributes.edge.set(attribute.labelfloat, true);
99
}
1010

@@ -33,7 +33,7 @@ export function groupToDot(
3333
return graphvizToDot(vizGraph);
3434
}
3535

36-
function addToVizGraphAndHighlight(graph: QueryGraph, vizGraph: ICluster, config?: DotGraphConfig) {
36+
function addToVizGraphAndHighlight(graph: QueryGraph, vizGraph: GraphBaseModel, config?: DotGraphConfig) {
3737
const state = addToVizGraph(graph, vizGraph, config?.noTerminal);
3838
highlightPaths(state, config?.highlightedPaths);
3939
}
@@ -64,7 +64,7 @@ type HighlitedPath = {
6464
color: string
6565
}
6666

67-
function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolean = false): QueryGraphState<INode, IEdge> {
67+
function addToVizGraph(graph: QueryGraph, vizGraph: GraphBaseModel, noTerminal: boolean = false): QueryGraphState<NodeModel, EdgeModel> {
6868
const vizSubGraphs = new Map();
6969
for (const source of graph.sources.keys()) {
7070
if (source != graph.name) {
@@ -76,12 +76,12 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea
7676
}));
7777
}
7878
}
79-
const getNode = function (vertex: Vertex): INode {
79+
const getNode = function (vertex: Vertex): NodeModel {
8080
const existingNode = state.getVertexState(vertex);
8181
if (existingNode) {
8282
return existingNode;
8383
}
84-
let newNode: INode;
84+
let newNode: NodeModel;
8585
if (vertex.source == graph.name) {
8686
newNode = vizGraph.createNode(vertex.type.name);
8787
} else {
@@ -94,13 +94,13 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea
9494
state.setVertexState(vertex, newNode);
9595
return newNode;
9696
}
97-
const pickGraphForEdge = function (head: Vertex, tail: Vertex): ICluster {
97+
const pickGraphForEdge = function (head: Vertex, tail: Vertex): GraphBaseModel {
9898
if (head.source == tail.source && head.source != graph.name) {
9999
return vizSubGraphs.get(head.source);
100100
}
101101
return vizGraph;
102102
}
103-
const state = new QueryGraphState<INode, IEdge>(graph);
103+
const state = new QueryGraphState<NodeModel, EdgeModel>(graph);
104104
const onEdge = function (edge: Edge): boolean {
105105
const head = edge.head;
106106
const tail = edge.tail;
@@ -119,11 +119,11 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea
119119
return state;
120120
}
121121

122-
function highlightPaths(state: QueryGraphState<INode, IEdge>, toHighlights?: HighlitedPath[]) {
122+
function highlightPaths(state: QueryGraphState<NodeModel, EdgeModel>, toHighlights?: HighlitedPath[]) {
123123
toHighlights?.forEach(h => highlightPath(state, h));
124124
}
125125

126-
function highlightPath(state: QueryGraphState<INode, IEdge>, toHighlight: HighlitedPath) {
126+
function highlightPath(state: QueryGraphState<NodeModel, EdgeModel>, toHighlight: HighlitedPath) {
127127
traversePath(toHighlight.path, e => {
128128
for (const vAttrs of [state.getVertexState(e.head)?.attributes, state.getVertexState(e.tail)?.attributes ]) {
129129
vAttrs?.set(attribute.color, toHighlight.color);

0 commit comments

Comments
 (0)