angel-dart / angel

[ARCHIVED] A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
https://angel-dart.dev/
MIT License
1.06k stars 67 forks source link

Having issue with hierarchical model generation using angel_orm_generator and build_runner #244

Closed tabula-rasa closed 3 years ago

tabula-rasa commented 4 years ago

Hi, Tobe! I saw your example from angel_orm_generator package with two-level model hierarchy, the build order there is set in build.yaml file. But what if I need to create models with more levels of hierarchy, say 3 or more, e.g : baz -> bar -> foo. Is there any easy work around? I get a Error running OrmGenerator Unsupported operation: Cannot apply relationship to field "bar" - dynamic is not assignable to Model. kind of error.

thosakwe commented 4 years ago

Sorry for the delayed response (I'm starting to think that GitHub puts a pixel in emails that marks notifications as read, which has caused me to miss a lot).

There is actually an upstream issue in package:build which prevents Dart files from referencing yet-to-be-generated code. For this reason, related models must:

It used to be where you could use a build.yaml file to split generation into distinct phases, with dependencies on each other, but someday that changed to where later outputs could not always read types from previously-generated code.

There was some movement on the issue, though. I wonder if they've since published a new build/analyzer version that may allow this again: https://github.com/dart-lang/build/issues/2389

Here's the issue I filed that directly talks about this: https://github.com/dart-lang/build/issues/2146