Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@SonyaOrlova
Copy link
Contributor

suggest to move resolving merge schemas conflicts to merge schemas handler

@SonyaOrlova SonyaOrlova force-pushed the bugfix-merge-schemas branch 2 times, most recently from 5daa672 to 126cbe6 Compare April 27, 2023 12:46
@igoradamenko
Copy link
Contributor

@Ge11ert, check this out, please 🙏

Copy link
Contributor

@Ge11ert Ge11ert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but have a few questions

action(first, second) {
if (!schema1.properties || !schema2.properties) return first;

const firstProperties = Object.keys(schema1.properties);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get values of required prop we use result (resulting schema after merge) and schema 2 (result[key], schema2[key]). Here we use original schema 1 and schema 2.

Is this intended?

And, btw, maybe it will be better to pass schema1 and schema 2 as action func args and not to rely on closure? Then we will be able to move propsToMerge and propsToOverride out of function and not to generate new consts on every function call. Up to you, as one says, but worth considering.


const optionalOverride = firstProperties
.filter(property => secondProperties.includes(property))
.filter(property => first.includes(property) && (!second || !second.includes(property)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple filters look a bit excessive. Can we merge them into one?


const optionalOverride = firstProperties
.filter(property => secondProperties.includes(property))
.filter(property => first.includes(property) && (!second || !second.includes(property)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you think, should we perform all checks in filter when there is no second at all? I mean, maybe we can check for !second right after schema1/2.properties check and exit early

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is no second at all, it exactly means that we need to override (firstRequired -> ['someProp'], secondRequired -> undefined => it means that someProp has to be optional)
On other comments - up to codewriter if it affects nothing. I changed it

@SonyaOrlova SonyaOrlova force-pushed the bugfix-merge-schemas branch from 126cbe6 to 38d640a Compare April 28, 2023 10:20
@SonyaOrlova SonyaOrlova force-pushed the bugfix-merge-schemas branch from 38d640a to 95465d3 Compare April 28, 2023 10:31
Copy link
Contributor

@Ge11ert Ge11ert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@igoradamenko approved

@igoradamenko
Copy link
Contributor

Build is failing due to the Coveralls issues: lemurheavy/coveralls-public#1708.

I'm ignoring them and gonna merge the PR because the previous builds were green.

@igoradamenko igoradamenko merged commit 4fc230c into master Apr 28, 2023
@igoradamenko igoradamenko deleted the bugfix-merge-schemas branch April 28, 2023 17:21
@igoradamenko
Copy link
Contributor

Landed in @funboxteam/[email protected].

@SonyaOrlova, @Ge11ert, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants