Open Tanner-Scadden opened 1 year ago
A spontaneous thought is that we could theoretically allow passing a generic to the .find
method, so that the user could describe the type they would expect back. It would look something like this:
const forms = await ogm.models("Form").find<{ id: string }>({ selectionSet: `{ id }` })
Though I agree having it infer the resulting type based on the input selection set would be really nice!
That would be a good starting point, especially if it can compare the generic to the original type to ensure it's possible!
Is your feature request related to a problem? Please describe. Types returned from the OGM do not match the selection set.
Describe the solution you'd like A way for us to have types generated either through the selection set given instead of the full type.
Ex:
Describe alternatives you've considered Could also add a way to pass in a selection object that mirrors the selection set, similar to a traditional ORM. However this would limit the ability to pass in arguments into nested selects.
Additional context Not sure if this is possible, but would add a lot of power to the OGM, especially when people want to use it in a restful or rpc API.