Skip to content

Commit

Permalink
update extension nodes placement
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaLysiuk committed Feb 9, 2024
1 parent f172761 commit 6af6933
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/editor-worker/src/tsAlgo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ParserField,
TypeSystemDefinition,
compileType,
TypeExtension,
} from "graphql-js-tree";
import * as d3 from "d3";
import { WorkerEvents } from "@/worker/validation.worker";
Expand Down Expand Up @@ -106,6 +107,30 @@ export const sortNodesTs = ({
const connections: NumberConnection[] = [];
const idempotentInsert = (n: ParserField, tname: string) => {
const relatedNode = nodes.find((n) => n.name === tname);
const extensionNodes = !Object.keys(TypeExtension).includes(n.data.type)
? nodes.filter(
(extNode) =>
Object.keys(TypeExtension).includes(extNode.data.type) &&
n.name === extNode.name
)
: [];
for (const extNode of extensionNodes) {
if (extNode.id === n.id) return;
if (
connections.find((c) => c.source === n.id && c.target === extNode.id)
) {
return;
}
if (
connections.find((c) => c.source === extNode.id && c.target === n.id)
) {
return;
}
connections.push({
source: n.id,
target: extNode.id,
});
}
if (relatedNode) {
if (relatedNode.id === n.id) return;
if (
Expand Down

0 comments on commit 6af6933

Please sign in to comment.