Base abstract class is referenced/instantiated when child class should be #1492
Labels
Community 👨👧
Something initiated by a community
Need More Info 🤷♂️
Further information is requested
Question ❔
Not future request, proposal or bug issue
Describe the Bug
Assume you have some type of union or polymorphic object as shown in the example. You may want to have an abstract value which can be set by any child/implementation. In many of the examples, this is shown as an abstract class with an
@ObjectType({ implements: BaseClass })
in children.However, when it comes to actually running the methods, it seems like they are being executed on the BaseClass instead of the ChildClass. This means that concrete base class methods cannot reference or use abstract methods on the base class (since they are not instantiated).
While I haven't spelunked enough to understand exactly what's going on, my hunch is that typegraphql is calling BaseClass.value() instead of ChildClass.value(). This distinction would not matter normally, but comes into play when you truly start using abstraction and inheritance.
To Reproduce
https://codesandbox.io/p/sandbox/typegraphql-v2-demo-forked-wkyhwm?file=/src/index.ts:106,33
Expected Behavior
The function as shown should work and return the value from the child class
Logs
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: