grats icon indicating copy to clipboard operation
grats copied to clipboard

Allow function fields to be generic

Open captbaritone opened this issue 1 year ago • 1 comments
trafficstars

/** @gqlField */
export function nodes<T>(connection: Connection<T>): T[] {
  return connection.edge.map(edge => edge.node);
}

Should act as a functional equivalent of a method on a generic class:

/** @gqlType */
class Connection<T> {
  // ... other fields/methods
  nodes(): T[] {
    return this.edges.map(edge => edge.node)
  }
}

captbaritone avatar Mar 23 '24 19:03 captbaritone