From f7c690c182d3a3eb9cbfccc5a2b6057d29edfa69 Mon Sep 17 00:00:00 2001
From: Milho001 <l.milhomemfrancochristino@uu.nl>
Date: Tue, 12 Nov 2024 17:58:07 +0000
Subject: [PATCH] feat(qb): changes due to query service refactor

---
 libs/config/src/envVariables.ts               |   1 -
 .../store/graphQueryResultSlice.ts            |  27 +--
 .../querybuilder/model/BackendQueryFormat.tsx |  20 +-
 .../pills/pillattributes/PillAttributes.tsx   |   1 -
 .../query-utils/query2backend.spec.ts         | 181 +++++++++---------
 .../querybuilder/query-utils/query2backend.ts |   6 +-
 libs/shared/lib/statistics/graphStatistics.ts |   6 +-
 .../statistics/tests/getNodeEdgeType.spec.ts  |  66 -------
 .../lib/statistics/utils/getNodeOrEdgeType.ts |  24 ---
 libs/shared/lib/statistics/utils/index.ts     |   1 -
 .../nodelinkvis/components/query2NL.tsx       |  14 +-
 11 files changed, 111 insertions(+), 236 deletions(-)
 delete mode 100644 libs/shared/lib/statistics/tests/getNodeEdgeType.spec.ts
 delete mode 100644 libs/shared/lib/statistics/utils/getNodeOrEdgeType.ts

diff --git a/libs/config/src/envVariables.ts b/libs/config/src/envVariables.ts
index cc8b8bb21..265cd9a98 100644
--- a/libs/config/src/envVariables.ts
+++ b/libs/config/src/envVariables.ts
@@ -4,7 +4,6 @@ export const envVar = {
   GRAPHPOLARIS_VERSION: import.meta.env.GRAPHPOLARIS_VERSION,
   BACKEND_URL: import.meta.env.BACKEND_URL,
   BACKEND_WSS_URL: import.meta.env.BACKEND_WSS_URL,
-  STAGING: import.meta.env.STAGING,
   SKIP_LOGIN: import.meta.env.SKIP_LOGIN,
   BACKEND_USER: import.meta.env.BACKEND_USER,
 
diff --git a/libs/shared/lib/data-access/store/graphQueryResultSlice.ts b/libs/shared/lib/data-access/store/graphQueryResultSlice.ts
index b6e7bf2dc..e40af60f7 100755
--- a/libs/shared/lib/data-access/store/graphQueryResultSlice.ts
+++ b/libs/shared/lib/data-access/store/graphQueryResultSlice.ts
@@ -15,13 +15,13 @@ export type NodeAttributes = { [key: string]: unknown };
 export interface GraphQueryResultFromBackend {
   nodes: {
     _id: string;
-    label?: string;
+    label: string;
     attributes: NodeAttributes;
   }[];
 
   edges: {
     _id: string;
-    label?: string;
+    label: string;
     attributes: NodeAttributes;
     from: string;
     to: string;
@@ -78,29 +78,6 @@ export const graphQueryBackend2graphQuery = (payload: GraphQueryResultFromBacken
   let nodes = [...nodeIDs].map((nodeID) => payload.nodes.find((node) => node._id === nodeID) as unknown as Node);
   let edges = [...edgeIDs].map((edgeID) => payload.edges.find((edge) => edge._id === edgeID) as unknown as Edge);
 
-  nodes = nodes.map((node) => {
-    let _node = { ...node };
-    // TODO!: only works for neo4j
-    let nodeType: string = node._id.split('/')[0];
-    let innerLabels = node?.attributes?.labels as string[];
-
-    if (innerLabels?.length > 0) nodeType = innerLabels[0] as string;
-
-    _node.label = nodeType;
-    return _node;
-  });
-
-  edges = edges.map((edge) => {
-    let _edge = { ...edge };
-    // TODO!: only works for neo4j
-    let edgeType: string = edge._id.split('/')[0];
-
-    if (!_edge._id.includes('/')) edgeType = edge.attributes.Type as string;
-
-    _edge.label = edgeType;
-    return _edge;
-  });
-
   const metaData = getGraphStatistics(payload);
 
   return { metaData, nodes, edges };
diff --git a/libs/shared/lib/querybuilder/model/BackendQueryFormat.tsx b/libs/shared/lib/querybuilder/model/BackendQueryFormat.tsx
index ace344272..bbeafd6f9 100644
--- a/libs/shared/lib/querybuilder/model/BackendQueryFormat.tsx
+++ b/libs/shared/lib/querybuilder/model/BackendQueryFormat.tsx
@@ -42,13 +42,13 @@ export interface BackendQueryFormat {
 
 /** Interface for an entity in the JSON for the query. */
 export interface QueryStruct {
-  ID: string;
+  id: string;
   node: NodeStruct;
 }
 
 export interface NodeStruct {
   label?: string;
-  ID?: string;
+  id?: string;
   logic?: AllLogicStatement;
   filter?: FilterStruct[];
   relation?: RelationStruct;
@@ -57,12 +57,12 @@ export interface NodeStruct {
 }
 
 export interface ExportNodeStruct {
-  ID: string;
+  id: string;
   attribute: string;
 }
 
 export interface LogicStruct {
-  ID: string;
+  id: string;
   attribute: string;
   operation: LogicOperationType;
 }
@@ -74,7 +74,7 @@ export interface FilterStruct {
 }
 
 export interface RelationStruct {
-  ID?: string;
+  id?: string;
   label?: string;
   depth: QuerySearchDepthStruct;
   direction: 'TO' | 'FROM' | 'BOTH';
@@ -92,14 +92,14 @@ export type LogicOperationType = 'AND' | 'OR';
 /** Interface for an entity in the JSON for the query. */
 export interface Entity {
   name: string;
-  ID: number;
+  id: number;
   constraints: Constraint[];
 }
 
 /** Interface for an relation in the JSON for the query. */
 export interface Relation {
   name: string;
-  ID: number;
+  id: number;
   fromType: string;
   fromID: number;
   toType: string;
@@ -111,7 +111,7 @@ export interface Relation {
 // /** Interface for an relation in the JSON for the query. */
 // export interface Relation {
 //   name: string;
-//   ID: number;
+//   id: number;
 //   fromType: string;
 //   fromID: number;
 //   toType: string;
@@ -153,7 +153,7 @@ export interface Constraint {
 
 // /** Interface for a function in the JSON for the query. */
 // export interface GroupBy {
-//   ID: number;
+//   id: number;
 
 //   groupType: string;
 //   groupID: number[];
@@ -170,7 +170,7 @@ export interface Constraint {
 
 // /** Interface for Machine Learning algorithm */
 export interface MachineLearning {
-  ID?: number;
+  id?: number;
   type: MLTypes;
   parameters?: string[];
 }
diff --git a/libs/shared/lib/querybuilder/pills/pillattributes/PillAttributes.tsx b/libs/shared/lib/querybuilder/pills/pillattributes/PillAttributes.tsx
index 21f1315cd..7061077ac 100644
--- a/libs/shared/lib/querybuilder/pills/pillattributes/PillAttributes.tsx
+++ b/libs/shared/lib/querybuilder/pills/pillattributes/PillAttributes.tsx
@@ -29,7 +29,6 @@ export const PillAttributes = (props: PillAttributesProps) => {
       {attributesOfInterest &&
         attributesOfInterest.map((showing, i) => {
           if (!showing) return null;
-          console.log('props.attributes', props.attributes);
           return (
             <PillAttributesItem
               key={props.attributes[i].handleData.attributeName || i}
diff --git a/libs/shared/lib/querybuilder/query-utils/query2backend.spec.ts b/libs/shared/lib/querybuilder/query-utils/query2backend.spec.ts
index 18fe1b7c7..8a39adb9d 100644
--- a/libs/shared/lib/querybuilder/query-utils/query2backend.spec.ts
+++ b/libs/shared/lib/querybuilder/query-utils/query2backend.spec.ts
@@ -21,6 +21,7 @@ const defaultSettings: QueryBuilderSettings = {
   depth: { min: 0, max: 1 },
   layout: 'manual',
   autocompleteRelation: true,
+  unionTypes: {},
 };
 
 describe('QueryUtils Entity and Relations', () => {
@@ -67,16 +68,16 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: '0',
+            id: '0',
             label: 'Airport 1',
             relation: {
-              ID: '1',
+              id: '1',
               label: 'Flight between airports',
               direction: 'TO',
               node: {
-                ID: '10',
+                id: '10',
                 label: 'Airport 2',
                 relation: undefined,
               },
@@ -131,16 +132,16 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e0',
+            id: 'e0',
             label: 'Airport 1',
             relation: {
-              ID: 'r1',
+              id: 'r1',
               label: 'Flight between airports',
               direction: 'TO',
               node: {
-                ID: 'e1',
+                id: 'e1',
                 label: 'Airport 2',
                 relation: undefined,
               },
@@ -148,16 +149,16 @@ describe('QueryUtils Entity and Relations', () => {
           },
         },
         {
-          ID: 'path_1',
+          id: 'path_1',
           node: {
-            ID: 'e12',
+            id: 'e12',
             label: 'Airport 12',
             relation: {
-              ID: 'r12',
+              id: 'r12',
               label: 'Flight between airports 2',
               direction: 'TO',
               node: {
-                ID: 'e22',
+                id: 'e22',
                 label: 'Airport 22',
                 relation: undefined,
               },
@@ -200,35 +201,35 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e2', label: 'Airport 2' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e2', label: 'Airport 2' } },
           },
         },
         {
-          ID: 'path_1',
+          id: 'path_1',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e22', label: 'Airport 22' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e22', label: 'Airport 22' } },
           },
         },
         {
-          ID: 'path_2',
+          id: 'path_2',
           node: {
-            ID: 'e12',
+            id: 'e12',
             label: 'Airport 12',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e2', label: 'Airport 2' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e2', label: 'Airport 2' } },
           },
         },
         {
-          ID: 'path_3',
+          id: 'path_3',
           node: {
-            ID: 'e12',
+            id: 'e12',
             label: 'Airport 12',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e22', label: 'Airport 22' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e22', label: 'Airport 22' } },
           },
         },
       ],
@@ -263,15 +264,15 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e0',
+            id: 'e0',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e1', label: 'Airport 2' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e1', label: 'Airport 2' } },
           },
         },
-        { ID: 'path_1', node: { ID: 'e12', label: 'Airport 12' } },
-        { ID: 'path_2', node: { ID: 'e22', label: 'Airport 22' } },
+        { id: 'path_1', node: { id: 'e12', label: 'Airport 12' } },
+        { id: 'path_2', node: { id: 'e22', label: 'Airport 22' } },
       ],
     };
     let ret = Query2BackendQuery('database', graph.export(), defaultSettings);
@@ -312,16 +313,16 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e0',
+            id: 'e0',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e1', label: 'Airport 2' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e1', label: 'Airport 2' } },
           },
         },
         {
-          ID: 'path_1',
-          node: { relation: { ID: 'r2', label: 'Flight between airports 2', direction: 'TO', node: {} } },
+          id: 'path_1',
+          node: { relation: { id: 'r2', label: 'Flight between airports 2', direction: 'TO', node: {} } },
         },
       ],
     };
@@ -351,11 +352,11 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e0',
+            id: 'e0',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: {} },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: {} },
           },
         },
       ],
@@ -386,9 +387,9 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e0', label: 'Airport 2' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e0', label: 'Airport 2' } },
           },
         },
       ],
@@ -434,19 +435,19 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e2', label: 'Airport 2' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e2', label: 'Airport 2' } },
           },
         },
         {
-          ID: 'path_1',
+          id: 'path_1',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
-            relation: { ID: 'r2', label: 'Flight between airports 2', direction: 'TO', node: { ID: 'e2', label: 'Airport 2' } },
+            relation: { id: 'r2', label: 'Flight between airports 2', direction: 'TO', node: { id: 'e2', label: 'Airport 2' } },
           },
         },
       ],
@@ -478,11 +479,11 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e1', label: 'Airport 1' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e1', label: 'Airport 1' } },
           },
         },
       ],
@@ -516,24 +517,24 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
             relation: {
-              ID: 'r1',
+              id: 'r1',
               label: 'Flight between airports',
               direction: 'TO',
-              node: { ID: 'e2', label: 'Airport 1', relation: undefined },
+              node: { id: 'e2', label: 'Airport 1', relation: undefined },
             },
           },
         },
         {
-          ID: 'path_1',
+          id: 'path_1',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e1', label: 'Airport 1' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e1', label: 'Airport 1' } },
           },
         },
       ],
@@ -567,19 +568,19 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e1', label: 'Airport 1' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e1', label: 'Airport 1' } },
           },
         },
         {
-          ID: 'path_1',
+          id: 'path_1',
           node: {
-            ID: 'e2',
+            id: 'e2',
             label: 'Airport 1',
-            relation: { ID: 'r1', label: 'Flight between airports', direction: 'TO', node: { ID: 'e1', label: 'Airport 1' } },
+            relation: { id: 'r1', label: 'Flight between airports', direction: 'TO', node: { id: 'e1', label: 'Airport 1' } },
           },
         },
       ],
@@ -600,11 +601,11 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
-            relation: { direction: 'BOTH', node: { ID: 'e2', label: 'Airport 1' } },
+            relation: { direction: 'BOTH', node: { id: 'e2', label: 'Airport 1' } },
           },
         },
       ],
@@ -644,13 +645,13 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
             relation: {
-              ID: 'r1',
+              id: 'r1',
               label: 'Flight between airports',
               direction: 'TO',
-              node: { relation: { ID: 'r2', label: 'Flight between airports 2', direction: 'TO', node: {} } },
+              node: { relation: { id: 'r2', label: 'Flight between airports 2', direction: 'TO', node: {} } },
             },
           },
         },
@@ -673,17 +674,17 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
             relation: {
               direction: 'BOTH',
               node: {
-                ID: 'e2', label: 'Airport 2',
+                id: 'e2', label: 'Airport 2',
                 relation: {
                   direction: 'BOTH',
-                  node: { ID: 'e1', label: 'Airport 1' }
+                  node: { id: 'e1', label: 'Airport 1' }
                 },
               }
             },
@@ -706,12 +707,12 @@ describe('QueryUtils Entity and Relations', () => {
       ...defaultQuery,
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1', label: 'Airport 1',
+            id: 'e1', label: 'Airport 1',
             relation: {
               direction: 'BOTH',
-              node: { ID: 'e1', label: 'Airport 1' }
+              node: { id: 'e1', label: 'Airport 1' }
             }
           },
         },
@@ -792,9 +793,9 @@ describe('QueryUtils with Logic', () => {
       machineLearning: [],
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
             relation: undefined,
           },
@@ -865,17 +866,17 @@ describe('QueryUtils with Logic', () => {
       machineLearning: [],
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
             relation: undefined,
           },
         },
         {
-          ID: 'path_1',
+          id: 'path_1',
           node: {
-            ID: 'e2',
+            id: 'e2',
             label: 'Airport 2',
             relation: undefined,
           },
@@ -933,9 +934,9 @@ describe('QueryUtils with Logic', () => {
       machineLearning: [],
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
             relation: undefined,
           },
@@ -984,9 +985,9 @@ describe('QueryUtils with Logic', () => {
       machineLearning: [],
       query: [
         {
-          ID: 'path_0',
+          id: 'path_0',
           node: {
-            ID: 'e1',
+            id: 'e1',
             label: 'Airport 1',
             relation: undefined,
           },
@@ -1045,26 +1046,26 @@ it('should no connections between entities and relations', () => {
     machineLearning: [],
     query: [
       {
-        ID: 'path_0',
+        id: 'path_0',
         node: {
-          ID: 'e1',
+          id: 'e1',
           label: 'Airport 1',
           relation: undefined,
         },
       },
       {
-        ID: 'path_1',
+        id: 'path_1',
         node: {
-          ID: 'e2',
+          id: 'e2',
           label: 'Airport 2',
           relation: undefined,
         },
       },
       {
-        ID: 'path_2',
+        id: 'path_2',
         node: {
           relation: {
-            ID: 'r1',
+            id: 'r1',
             label: 'Relation 1',
             direction: 'TO',
             node: {},
diff --git a/libs/shared/lib/querybuilder/query-utils/query2backend.ts b/libs/shared/lib/querybuilder/query-utils/query2backend.ts
index 670d1c1f8..510703dc4 100644
--- a/libs/shared/lib/querybuilder/query-utils/query2backend.ts
+++ b/libs/shared/lib/querybuilder/query-utils/query2backend.ts
@@ -268,7 +268,7 @@ export function Query2BackendQuery(
     if (currNode.type === QueryElementTypes.Relation) {
       const _currNode = currNode as RelationNodeAttributes;
       const ret: RelationStruct = {
-        ID: _currNode.id,
+        id: _currNode.id,
         label: _currNode.name || undefined,
         depth: _currNode.depth,
         direction: !_currNode.direction || _currNode.direction === 'right' ? 'TO' : _currNode.direction === 'left' ? 'FROM' : 'BOTH',
@@ -277,7 +277,7 @@ export function Query2BackendQuery(
       return ret;
     } else if (currNode.type === QueryElementTypes.Entity) {
       const ret: NodeStruct = {
-        ID: currNode?.id,
+        id: currNode?.id,
         label: currNode?.name,
         // logic: LogicStruct[];
         // subQuery?: QueryStruct;
@@ -292,7 +292,7 @@ export function Query2BackendQuery(
 
   query.query = graphSequenceChunks.map((chunk, i) => {
     const ret: QueryStruct = {
-      ID: 'path_' + i, //TODO: chunk[0].id ||
+      id: 'path_' + i, //TODO: chunk[0].id ||
       node: processConnection(chunk, 0),
     };
     return ret;
diff --git a/libs/shared/lib/statistics/graphStatistics.ts b/libs/shared/lib/statistics/graphStatistics.ts
index 8e1d79c18..2cafd971a 100644
--- a/libs/shared/lib/statistics/graphStatistics.ts
+++ b/libs/shared/lib/statistics/graphStatistics.ts
@@ -1,6 +1,6 @@
 import { GraphQueryResultFromBackend } from '../data-access/store/graphQueryResultSlice';
 import { GraphStatistics } from './statistics.types';
-import { getAttributeType, getEdgeType, getNodeLabel, initializeStatistics, updateStatistics } from './utils';
+import { getAttributeType, initializeStatistics, updateStatistics } from './utils';
 
 const getGraphStatistics = (graph: GraphQueryResultFromBackend): GraphStatistics => {
   const { nodes, edges } = graph;
@@ -19,7 +19,7 @@ const getGraphStatistics = (graph: GraphQueryResultFromBackend): GraphStatistics
 
   // attributes based statistics
   nodes.forEach((node) => {
-    const nodeType = getNodeLabel(node);
+    const nodeType = node.label;
     if (!metaData.nodes.labels.includes(nodeType)) {
       metaData.nodes.labels.push(nodeType);
     }
@@ -41,7 +41,7 @@ const getGraphStatistics = (graph: GraphQueryResultFromBackend): GraphStatistics
 
   // Process edges
   edges.forEach((edge) => {
-    const edgeType = getEdgeType(edge);
+    const edgeType = edge.label;
     if (!metaData.edges.labels.includes(edgeType)) {
       metaData.edges.labels.push(edgeType);
     }
diff --git a/libs/shared/lib/statistics/tests/getNodeEdgeType.spec.ts b/libs/shared/lib/statistics/tests/getNodeEdgeType.spec.ts
deleted file mode 100644
index 5e91e5fa1..000000000
--- a/libs/shared/lib/statistics/tests/getNodeEdgeType.spec.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { describe, it, expect } from 'vitest';
-import { getNodeLabel, getEdgeType } from '../utils/getNodeOrEdgeType';
-import { GraphQueryResultFromBackend } from '../../data-access/store/graphQueryResultSlice';
-
-describe('getNodeLabel', () => {
-  it('should return node type based on _id', () => {
-    const node: GraphQueryResultFromBackend['nodes'][number] = {
-      _id: 'Person/123',
-      attributes: {},
-    };
-    const label = getNodeLabel(node);
-    expect(label).toBe('Person');
-  });
-
-  it('should return node label if present', () => {
-    const node: GraphQueryResultFromBackend['nodes'][number] = {
-      _id: 'Person/123',
-      label: 'Student',
-      attributes: {},
-    };
-    const label = getNodeLabel(node);
-    expect(label).toBe('Student');
-  });
-
-  it('should return first label from attributes if labels array is present', () => {
-    const node: GraphQueryResultFromBackend['nodes'][number] = {
-      _id: 'Person/123',
-      attributes: { labels: ['Teacher', 'Mentor'] },
-    };
-    const label = getNodeLabel(node);
-    expect(label).toBe('Teacher');
-  });
-
-  it('should return _id-based node type if labels array is empty', () => {
-    const node: GraphQueryResultFromBackend['nodes'][number] = {
-      _id: 'Person/123',
-      attributes: { labels: [] },
-    };
-    const label = getNodeLabel(node);
-    expect(label).toBe('Person');
-  });
-});
-
-describe('getEdgeType', () => {
-  it('should return edge type based on _id', () => {
-    const edge: GraphQueryResultFromBackend['edges'][number] = {
-      _id: 'Relationship/456',
-      attributes: {},
-      from: 'Person/123',
-      to: 'Person/456',
-    };
-    const edgeType = getEdgeType(edge);
-    expect(edgeType).toBe('Relationship');
-  });
-
-  it('should return edge type from attributes if _id does not contain /', () => {
-    const edge: GraphQueryResultFromBackend['edges'][number] = {
-      _id: '456',
-      attributes: { Type: 'FRIENDS_WITH' },
-      from: 'Person/123',
-      to: 'Person/456',
-    };
-    const edgeType = getEdgeType(edge);
-    expect(edgeType).toBe('FRIENDS_WITH');
-  });
-});
diff --git a/libs/shared/lib/statistics/utils/getNodeOrEdgeType.ts b/libs/shared/lib/statistics/utils/getNodeOrEdgeType.ts
deleted file mode 100644
index 3ebc86131..000000000
--- a/libs/shared/lib/statistics/utils/getNodeOrEdgeType.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { GraphQueryResultFromBackend } from '../../data-access/store/graphQueryResultSlice';
-
-// Get node type based on _id or label
-const getNodeLabel = (node: GraphQueryResultFromBackend['nodes'][number]): string => {
-  let nodeType = node._id.split('/')[0];
-  if (node.label) nodeType = node.label;
-  else if (Array.isArray(node.attributes?.labels) && node.attributes.labels.length > 0) {
-    nodeType = node.attributes.labels[0]; // Safely access first label
-  }
-
-  return nodeType;
-};
-
-// Get edge type based on _id or attributes
-const getEdgeType = (edge: GraphQueryResultFromBackend['edges'][number]): string => {
-  let edgeType = edge._id.split('/')[0];
-  if (!edge._id.includes('/')) {
-    edgeType = edge.attributes.Type as string;
-  }
-  if (edge.label) edgeType = edge.label;
-  return edgeType;
-};
-
-export { getNodeLabel, getEdgeType };
diff --git a/libs/shared/lib/statistics/utils/index.ts b/libs/shared/lib/statistics/utils/index.ts
index 41a5c208d..4fb895ded 100644
--- a/libs/shared/lib/statistics/utils/index.ts
+++ b/libs/shared/lib/statistics/utils/index.ts
@@ -1,4 +1,3 @@
 export * from './getAttributeType';
-export * from './getNodeOrEdgeType';
 export * from './attributeStats';
 export * from './updateStatistics';
diff --git a/libs/shared/lib/vis/visualizations/nodelinkvis/components/query2NL.tsx b/libs/shared/lib/vis/visualizations/nodelinkvis/components/query2NL.tsx
index 3e649a991..79f925555 100644
--- a/libs/shared/lib/vis/visualizations/nodelinkvis/components/query2NL.tsx
+++ b/libs/shared/lib/vis/visualizations/nodelinkvis/components/query2NL.tsx
@@ -161,18 +161,8 @@ export function parseQueryResult(queryResult: GraphQueryResult, ml: ML, options:
     const nodeId = queryResult.nodes[i]._id;
     // for datasets without label, label is included in id. eg. "kamerleden/112"
     //const entityType = queryResult.nodes[i].label;
-    let entityType: string;
     const node = queryResult.nodes[i];
-
-    if (node.label === undefined) {
-      if (node.attributes.labels !== undefined && Array.isArray(node.attributes.labels)) {
-        entityType = node.attributes.labels[0];
-      } else {
-        entityType = node._id.split('/')[0];
-      }
-    } else {
-      entityType = node.label;
-    }
+    const entityType: string = node.label;
 
     // The preferred text to be shown on top of the node
     let preferredText = nodeId;
@@ -264,7 +254,7 @@ export function parseQueryResult(queryResult: GraphQueryResult, ml: ML, options:
         name: uniqueEdges[i].attributes.Type,
         mlEdge: false,
         color: 0x000000,
-        attributes: uniqueEdges[i].attributes
+        attributes: uniqueEdges[i].attributes,
       };
       ret.links[toAdd.id] = toAdd;
     }
-- 
GitLab