From ded459faff8f6694006d096ee8f4bd480dd6afb2 Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Wed, 13 Dec 2023 14:55:47 -0500 Subject: [PATCH] Reapply "Merge branch 'batch-limit' of https://github.com/biothings/bte_trapi_query_graph_handler into dev" This reverts commit cca40d0702664b4811c0c007a2dd6e47833537c8. --- src/query_graph.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/query_graph.ts b/src/query_graph.ts index 2b78ab9d..e9b6dc19 100644 --- a/src/query_graph.ts +++ b/src/query_graph.ts @@ -57,6 +57,14 @@ export default class QueryGraph { } } + _validateBatchSize(queryGraph: TrapiQueryGraph): void { + Object.entries(queryGraph.nodes).forEach(([nodeID, node]) => { + if (node.ids.length > 150) { + throw new InvalidQueryGraphError(`Query node ${nodeID} exceeds batch size limit.`); + } + }); + } + _validateDuplicateEdges(queryGraph: TrapiQueryGraph): void { const edgeSet = new Set(); for (const edgeID in queryGraph.edges) { @@ -182,6 +190,7 @@ export default class QueryGraph { this._validateDuplicateEdges(queryGraph); this._validateNodeProperties(queryGraph); this._validateEdgeProperties(queryGraph); + this._validateBatchSize(queryGraph); this._validateCycles(queryGraph); this._validateNoDuplicateQualifierTypes(queryGraph); }