Skip to content

Commit dbea2fe

Browse files
committed
refactor(web): simplify addNode type to require minimal node info
The addNode function now accepts GraphNodeInput (entityId, entityType, label) instead of full GraphNode, since x/y coordinates and externalIds are not needed when adding a node to the graph list.
1 parent 6544179 commit dbea2fe

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apps/web/src/hooks/use-graph-list.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ import { useStorageProvider } from '@/contexts/storage-provider-context';
1515

1616
const LOG_PREFIX = 'use-graph-list';
1717

18+
/** Minimal node input for adding to graph list - only needs identifying info */
19+
export type GraphNodeInput = Pick<GraphNode, 'entityId' | 'entityType' | 'label'>;
20+
1821
export interface UseGraphListReturn {
1922
nodes: GraphListNode[];
2023
loading: boolean;
2124
error: Error | null;
22-
addNode: (node: GraphNode, provenance: GraphProvenance) => Promise<void>;
25+
addNode: (node: GraphNodeInput, provenance: GraphProvenance) => Promise<void>;
2326
removeNode: (entityId: string) => Promise<void>;
2427
clearList: () => Promise<void>;
2528
}
@@ -74,7 +77,7 @@ export const useGraphList = (): UseGraphListReturn => {
7477
* Uses optimistic updates for better UX
7578
*/
7679
const addNode = useCallback(
77-
async (node: GraphNode, provenance: GraphProvenance): Promise<void> => {
80+
async (node: GraphNodeInput, provenance: GraphProvenance): Promise<void> => {
7881
const newEntry: GraphListNode = {
7982
id: node.entityId, // Use entityId as temporary id for optimistic update
8083
entityId: node.entityId,

0 commit comments

Comments
 (0)