grats icon indicating copy to clipboard operation
grats copied to clipboard

Add the ability to define fields using static methods just like exported functions

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

Would require that the class be exported, but would enable grouping top level query/mutation fields in models:

/** @gqlType */
class User {
  /** @gqlField */
  name: string;
  
  /** @gqlField */
  static getUser(_: Query, args: {id: ID}): User {
     return new User { name: "Jordan" };
  }
  
  /** @gqlField */
  static deleteUser(_: Mutation, args: {id: ID}): bolean {
     // TODO: Delete user
     return true;
  }
}

captbaritone avatar Mar 22 '24 20:03 captbaritone