How can I write a function that will accept injectionObject and modify currentObject? I believe this is sort of how GraphQL works if I'm not mistaken. I need to achieve this effect in plain JS.
//Object to inject into current object
const injectionObject = {
pages: {
about: {
title: 'Changed About Page'
}
}
}
//Object that requires modification based on above object
const currentObject = {
pages: {
home: {
title: 'Home Page',
description: 'This is the home page'
},
about: {
title: 'About Page',
description: 'This is the about page'
}
}
}
//output
const outputObject = {
pages: {
home: {
title: 'Home Page',
description: 'This is the home page'
},
about: {
title: 'Changed About Page', //Only this was affected
description: 'This is the about page'
}
}
}