Skip to content

Commit d76a379

Browse files
committed
sort typelist based on pagerank + add circo root
1 parent 85e8094 commit d76a379

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/components/doc-explorer/TypeList.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,23 @@ export default function TypeList(props: TypeListProps) {
2020

2121
let types: Array<GraphQLNamedType>;
2222
if (typeGraph.rootType == null) {
23+
const { pageRanks } = typeGraph.schema.extensions;
2324
types = Array.from(typeGraph.entities.values())
2425
.map((entity) => entity.type)
2526
.filter((type) => isMatch(type.name, filter));
27+
types.sort((a, b) => {
28+
const rankA = pageRanks.get(a.name) ?? 0;
29+
const rankB = pageRanks.get(b.name) ?? 0;
30+
return rankA - rankB;
31+
});
2632
} else {
2733
types = Array.from(typeGraph.nodes.values()).filter((type) =>
2834
isMatch(type.name, filter),
2935
);
30-
}
3136

32-
// sort alphabetically but root is always be first
33-
types.sort((a, b) => (isRoot(b) ? 1 : a.name.localeCompare(b.name)));
37+
// sort alphabetically but root is always be first
38+
types.sort((a, b) => (isRoot(b) ? 1 : a.name.localeCompare(b.name)));
39+
}
3440

3541
return (
3642
<div className="doc-explorer-type-list">

src/graph/dot.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ export function getDot(typeGraph: TypeGraph): Graph {
136136
ranksep: 2.0,
137137
layout:
138138
typeGraph.rootType == null && graphDensity > 0.4 ? 'circo' : 'dot',
139+
// @ts-expect-error FIXME in dotviz
140+
root: schema.getQueryType()?.name ?? undefined,
139141
},
140142
nodeAttributes: {
141143
fontsize: '16',

0 commit comments

Comments
 (0)