Thank you for your time and explanation. I also think that the codegen must be responsible to generate the correct types but wanted to ask if this problem was discussed here before and you perfectly answered this.
Just for further explanation as I felt my issue wasn’t clear (don’t bother to read, it’s completely unrelated to dgraph and more an issue with the codegen I’m using):
The codegen I’m using takes this schema:
type Foo {
m: [Bar!]! @hasInverse(field: foo)
}
interface Bar {
foo: Foo!
}
type Blub implements Bar {
...
}
type Blabla implements Bar {
...
}
generates theses types:
export type Bar = {
foo: Foo;
};
export type Blabla = Bar & {
__typename?: 'Blaba';
foo: Foo;
...
};
export type Blub = Bar & {
__typename?: 'Blaba';
foo: Foo;
...
};
export type Foo = {
__typename?: 'Foo';
m: Array<Bar>;
};
As you can see, filed m of Foo is of type Bar. So I have no way of differentiating between the actual types (or read their fields) when using these generated types. Which defeats the purpose of code generation in this case.
This is of course completely unrelated to dgraph and I opened an issue on the codegen repo, I just had the feeling to explain myself.