Extending a type with extra fields (without adding them to the class directly) #2005
Unanswered
terminalnode
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Lets say I have a type:
This type is shared between ServiceA and ServiceB. I can add service specific fields to it by creating this class in ServiceA:
and adding a federated type resolver, so that when ServiceB emits a
MyType
the router will fetchserviceSpecificField
from ServiceA.I have something like this for a relatively simple class and it seems to work well, but now I want to add it to a class that has something like ~30 fields with a lot of directives and such on top. Duplicating this class to both services is bit of a pain, and keeping them in sync is even worse.
If I could just define an extension method:
Or if I could define some type of standalone field resolver:
or something like that. This would also be handy for non-federated types with a lot of fields, to keep them clean and perhaps be able to unit test them individually.
Beta Was this translation helpful? Give feedback.
All reactions