import type { Schema } from '@vegaprotocol/types'; type Edge = { node: T; }; type Connection = { edges?: Schema.Maybe>>; }; export function getNodes< T, A extends Edge = Edge, 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; }, []); }