data
data copied to clipboard
manyOf relationship in nullable objects
With the feature introduced by https://github.com/mswjs/data/pull/257, setting a nullable object to null that has a nested relationship (tested with ManyOf
), results in a TypeError: Object.defineProperty called on non-object
E.g:
const db = factory({
a: {
id: primaryKey(() => 1),
nested: nullable({
b: manyOf('b') // problematic
})
},
b: {
id: primaryKey(() => 1)
}
});
// Works fine
db.a.create()
// Works fine
db.a.create({ nested: { b: [db.b.create()] } })
// Error
db.a.create({ nested: null })
Object.defineProperty
in definePropertyAtPath is called with null
(parent
)
CC @yishayweb
Hey @diogomiguel Only saw now that my PR was merged I will try to take a look at the issue you raised here