Improving typings of depth
in collections
#6161
tyteen4a03
started this conversation in
Feature Requests & Ideas
Replies: 1 comment
-
Hey there - a solid fix here is super important for sure, but it's more complicated than depth alone unfortunately. For example, you might have access control that prevents a user from reading a document - or, in MongoDB at least, you might have deleted a document which will then prevent the document from populating successfully. Basically - this problem runs a bit deeper than solely being based on depth alone. But I agree, something needs to be done here. We will figure out a solution one way or another. Will bring this forward in our priorities list. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now, Payload types does not have the concept of depth-aware types. For a typical collection, when a relationship type is generated into the schema, it hints
RelatedEntity | number
(orstring
depending on your ID type). This isn't useful behaviour for the consumers as they now need to either cast the variable toRelatedEntity
to get type completion or do some type guard checks to make sure the variable resolved toRelatedEntity
.I'm not sure how this can be improved in TypeScript but just throwing this out there.
Beta Was this translation helpful? Give feedback.
All reactions