tql icon indicating copy to clipboard operation
tql copied to clipboard

Restrict `Selector` methods to returning appropriate `Field`'s

Open timkendall opened this issue 5 years ago • 1 comments

We have the power to restrict what types of Field's are returned (i.e "selected") from a Selector object's method.

Some possible implementation options:

  • Inline define union of field names (as shown here)
  • Define a union of the entire selection available to a type (ex. type UserSelection = Array<Field<'id', [], string> | Field<'friends', [], any>>>) (this might be the key to getting nullable / list type support)
  • Note: This is also a critical piece for supporting "native" fragments

timkendall avatar Dec 16 '20 05:12 timkendall

TypeScript 4.7 add's support for constraints on infer'd types which may make this cleaner to implement.

timkendall avatar Jun 04 '22 23:06 timkendall