mswjs / data

Data modeling and relation library for testing JavaScript applications.
https://npm.im/@mswjs/data
MIT License
827 stars 52 forks source link

Cannot define model to have bidirectional relationships for child and parent #139

Closed tinleym closed 2 years ago

tinleym commented 3 years ago

Using 0.7.0, I'm trying to create a hierarchy where Model A is a parent to Model B, which is in turn a parent to Model C. To preserve the links between them, a middle node like Model B would contain reciprocated references to its parent (A) and its child (C). Something, however, seems to be going awry:

https://codesandbox.io/s/dawn-sunset-4weoz?file=/src/App.js

Note that in the example above, commenting out either update will remove the error.

Some context... Traversable, two-way relationships are a GraphQL implementation pattern. If you're exposing a schema, and you have a fragment coupled to a component, you might want that fragment to retrieve data up and/or down its hierarchy. It's possible to work around this limitation as the library stands (and this library's great), it's just messier.

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 0.9.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: