mixins which can be easily "sprinkled" onto any class in your existing hierarchy.
At runtime method fields on the mixin run in the context of a class where you apply them, but
typescript doesn't know that, so you have to explicitly set this
parameter, as shown:
NOTE: same as when defining a type
, you can define a mixin
prop value as a thunk to be safe from circular dependencies:
Mixins and interfaces might seem similar at first glance, but they do have different purpose.
If you use @InterfaceType
it will add and interface type to your GQL schema. Whereas mixins do not add a new complex type to you schema.
Instead they only enhance the existing ObjectType where you apply them. In that regard they are just a helper to keep your code DRY when you need to share some fields across multiple ObjectTypes.