aspen-cloud/triplit

No option to include relations in type interface

marcos-acosta opened this issue · 2 comments

Hi! Enjoying your product so far, thanks for developing!

A simple situation that arises is defining a relation in the schema via example_relation: S.Relation*, but when I create a type to use in the rest of my application via type X = Entity<typeof schema, "table-name">, there is no way to ask it to include any of those relations in the way we can when actually querying the data via .query("table-name").include("example_relation"). So the Linter complains that example_relation doesn't exist on the object, even when it does.

The workaround is to compose a new type, which is fine, but a little annoying. I assumed a simple improvement could be to add all relational fields as optional fields when generating the type?

I think what you're looking for is the EntityWithSelection type which needs to be added to our docs. You can read about it in the blog here. Thanks for flagging.

That's exactly what I was looking for, thanks!