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

5 lines
222 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[] } | undefined): T[] {
return connection?.nodes ?? [];
}