The @hasInverse directive doesn’t work here because inputOf and outputOf are referencing the interface IArtifact and not the type ScriptArtifact. In other words, it doesn’t recognize that ScriptArtifact is implementing IArtifact.
My question is how can I make it work and if it is currently impossible what workaround you might suggest.
Yes, I tried reproducing this and it didn’t work.
Possible Workaround:
In case inputOf and outputOf field is only going to be used to store inverse edges of ScriptArtifact and not used in any other derived types from IArtifact, you may make inputOf and outputOf of types, [ScriptArtifact!] and ScriptArtifact respectively.
In case other derived types of IArtifact are also going to have inputs and output field and its inverse is going to be stored in inputOf and outputOf, you may consider keeping inputs and output as a field of IArtifact rather than ScriptArtifact
The thing is that not all IArtifact implementations have inputs and outpus.
Also all IObjectArtifacts might be an input or an output of the IArtifacts.
These are the rules of my app’s data modeling.
I need something that will alow that model.
In the mean time I chose option number 1 because currently I only have ScriptArtifacts but soon we might have more Artifacts.