-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEC-38] Fix ProductProjection
model reference properties
#638
base: main
Are you sure you want to change the base?
Conversation
|
ProductProjection
model reference propertiesProductProjection
model reference properties
let stateRef: TReferenceGraphql | null = null; | ||
if (fields.state) { | ||
const restState = buildField(fields.state, 'rest'); | ||
stateRef = buildField(fields.state, 'graphql') as TReferenceGraphql; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the nested model in the default representation holds a Reference
, it would be great that we could build the obj
property of the reference for the graphql output but we can't build nested properties in isolation and the graphql transformer of the Reference
model removes the obj
property since it's not part of that representation. So the alternative I found is to build the rest representation and use some its values to create a new graphql model and populate it with it.
Technically this is not 100% right as we would need to overwrite all create graphql instance with the values from the rest one but I can't see a way to do it in a maintainable way.
Hey @CarlosCortizasCT, I just finished a fix on the StandalonePrice model transformers. If that can be of any help, let me know |
Hi @nima-ct Thanks for the heads up. It seems the work of your PR is part of what I've done here. |
Description
It all started when migrating some tests in the MC Products application which started to fail when I used the
ProductProjection
model.The issue was in this specific function as we are accessing some properties of the
productType
property of the rest representation for theProductProjection
model.In the test data models, whenever we need to deal with a reference, we use the
Reference
model which creates an object with anid
andtypeId
properties by default. Also, in the rest transformers, we create anobj
property which is supposed to hold the referenced object model but we're creating that one only with its ID and nothing else. That means that, when tests need to access any property of that referenced model, it's not there.First thing I did is to update the
Reference
model to allow customization of theobj
property so consumers can actually populate the reference with an actual referenced object.Then I had to update the
ProductProjection
model so all references are created with a properobj
property.After that, I also found another models that were not using references correctly so I needed to update them as well.
Technically speaking this could be a breaking change because we're changing the types of some models properties (specially in the REST version) but I see them more like a fix because the types we were using didn't seem correct.
TODO