tql
tql copied to clipboard
Restrict `Selector` methods to returning appropriate `Field`'s
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
TypeScript 4.7 add's support for constraints on infer'd types which may make this cleaner to implement.