Redefining Fields on Inherited Types

#1

I have a Type (TypeB) that extends TypeA. TypeB redefines the path of foreign key relationship that populated fieldA.

Please refer to the below:

extendable TypeA {
fieldA: [TypeD] (valid.path.a)
}

TypeB extends TypeA {
fieldA: [TypeD] (valid.path.b)
}

My question:
When I do TypeB.fetch({filter: “id == ‘sampleID’ && exists(fieldA)”}) – I get a valid response of the item I query.

When I TypeA.fetch({filter: “id == ‘sampleID’ && exists(fieldA)”}) (same query as above, but executed on TypeA) – I return ‘no content’.

Should I expect to see data returned by the second query? Or should I make a new field on TypeB that doesn’t try to overwrite the logic of the foreign key relationship in TypeA?

0 Likes

#2

I’m not sure what you are trying to accomplish here but in general this is a bad idea. Since every TypeB isA TypeA, every instance of TypeB would have a different value for the field fieldA if fetched from TypeB than it would for typeA.

If this represents a real world scenario, please file a ticket with a more representative example and I’ll take a look to see if there is a gap where we need to add support for something or possibly return an error message if not supported.

0 Likes

#3

Sounds good, Thank you, Tom.

0 Likes