Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static getGraphqlWithoutRootSchema = (schema: string): string => {
const basicDefinitions = Definitions.generate([]);
const tree = TreeToNodes.resolveTree(Parser.parse(schema), basicDefinitions);
const nodes = tree.nodes.map((n) => ({
...n,
options: n.options.filter((no) => !(no in OperationType)),
}));
return NodesToTree.parse(nodes, tree.links);
};
loadLibraries = (schema?: string): void => {
if (!schema) {
return;
}
let basicDefinitions = Definitions.generate([]);
this.stichesCode = schema;
this.stitchNodes = TreeToNodes.resolveTree(Parser.parse(this.stichesCode), basicDefinitions);
basicDefinitions = Definitions.generate(this.stitchNodes.nodes);
const rememberBasicDefinitions = [...basicDefinitions];
this.stitchNodes = TreeToNodes.resolveTree(Parser.parse(this.stichesCode), basicDefinitions);
this.stitchDefinitions = basicDefinitions.filter((bd) => !rememberBasicDefinitions.find((rbd) => rbd.id === bd.id));
};
screenShot = async () => this.diagram!.screenShot();
loadGraphQL = (schema: string, forceZero?: boolean) => {
const zeroGraph = this.schema.length === 0 && !!schema;
this.definitions = Definitions.generate(this.stitchNodes.nodes).concat(this.stitchDefinitions!);
this.diagram!.setDefinitions(this.definitions);
if (schema.length === 0) {
this.resetGraph();
return;
}
const result = TreeToNodes.resolveTree(
Parser.parse(
schema + this.stichesCode,
this.stitchNodes.nodes.filter((n) => n.definition.root).map((n) => n.name),
),
this.definitions,
);
this.diagram!.setDefinitions(this.definitions);
this.load(result.nodes, result.links);
if (zeroGraph || forceZero) {
this.zeroGraph();
}
};
centerOnNodeByID = (id: string) => {