graphiti-api/spraypaint.js

Cyclic dependencies in ES2015

Opened this issue · 1 comments

Hey, I've been looking into graphitti and saw that you use classes to define relationships in the JS Client.
I'm currently using https://github.com/ghidoz/angular2-jsonapi with the "jsonapi suite" and they use a similar approach for this. But while using it I've had to upgrade to a new angular version, which also upgraded my "target" in tsconfig to es2015.

Now the issue is that it seems that when you change the target, you can no longer define classes that depend on each other in this way, see: ghidoz/angular2-jsonapi#236 (comment). Meaning if you define Post which hasMany Comments, but Comment also belongsTo Post it would throw a Uncaught ReferenceError: Cannot access '<insert class herr>' before initialization error.

Would this be an issue with spraypaint.js as well?

@piotrpalek I came across this issue because I was writing tests and started getting that exact initialization error, but it seems to be because I had my models setup incorrectly.

So to answer your question: Not that I've seen, yet, when things are setup right.