ProjectNestedValue type

Narrows a relationship value to the selected keys TKeys, keeping its object or array shape (including readonly arrays), null, and undefined.

type ProjectNestedValue<TValue, TKeys> = TValue extends null | undefined
  ? TValue
  : TValue extends readonly TItem[]
  ? TValue extends TMutableItem[]
    ? ProjectNestedElement<TMutableItem, TKeys>[]
    : readonly ProjectNestedElement<TItem, TKeys>[]
  : TValue extends object
  ? GraphQLPick<TValue, Extract<TKeys, keyof TValue>>
  : never