-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat(types): add util to transform get response to an update request #6289
Conversation
🦋 Changeset detectedLatest commit: 40be54d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
@riqwan - can you add more context to the functionality here. It's hard to decode as is; a few examples in the PR description would be very helpful |
@riqwan, just bumping this one. Is this PR still relevant? If so, can I get you to add some examples of what this introduces? |
Added a description, let me know if that helps 🤞🏻 |
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.
LGTM
what:
RESOLVES CORE-1687
Given an update data object, we can infer the
fields
andselects
of a data object using a util we already have -getSelectsAndRelationsFromObjectArray
. Using thefields
andselects
, we can call either the moduleretrieve
orlist
method to get a snapshot of the data down to its exact attributes. We can pass this data into the revert step.In the revert step, we just need to convert the snapshot received from
retrieve
orlist
to a shape that theupdate
methods will accept. The util that is introduced in this PR aims to do exactly that, so that the revert step looks as simple as:entity before update:
This is how the util will transform the data for different types of attributes in the object:
simple attributes:
one to one relationship:
one to many / many to many relationship:
all together: