dset icon indicating copy to clipboard operation
dset copied to clipboard

Merging objects at the root results in a no-op

Open ozziek opened this issue 3 years ago • 0 comments

👋 I believe I have discovered a bug in this library based on GraphiQL usage of the library. If given:

import { dset } from "dset/merge"
let input = {};
dset(input, [], { hero: { id: "A" }});
console.log(input)
// output: {}
// expected: { hero: { id: "A" } }

In the case of GraphQL, this can happen if a field is deferred at the root level (example test case from the reference implementation).

Example commit with test case and a fix: https://github.com/kirkbyo/dset/commit/ffc84ff8f98121cbf5df590c6917deb7936c4d52

Happy to open that commit as a PR here if you would prefer.

ozziek avatar Mar 14 '22 20:03 ozziek