import type { Schema } from '@vegaprotocol/types'; export type Node = { __typename?: string; node: T; }; export type Connection = { __typename?: string; edges?: Schema.Maybe>>; }; export function getNodes< T, A extends Node = Node, B extends Connection = Connection >(data?: B | null, filterBy?: (item?: T | null) => boolean) { const edges = data?.edges || []; return edges.reduce((acc, edge) => { if (edge?.node && (filterBy ? filterBy(edge?.node) : true)) { acc.push(edge.node); } return acc; }, []); }