captbaritone / grats

Implementation-First GraphQL for TypeScript
https://grats.capt.dev
MIT License
309 stars 16 forks source link

Allow function fields to be generic #135

Open captbaritone opened 8 months ago

captbaritone commented 8 months ago
/** @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)
  }
}