Files
wp-headless/wp-content/themes/moonshine/shared/utils/graphql.ts

5 lines
236 B
TypeScript

// Helper: Extracts nodes from a GraphQL connection object, returning an empty array if nodes are absent.
export function extractNodes<T>(connection: { nodes?: T[] } | null | undefined): T[] {
return connection?.nodes || [] as T[];
}