grats
grats copied to clipboard
Allow function fields to be generic
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)
}
}