-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing related object not in the store #18
Comments
Hey @JakeDluhy, it is supposed to normalize data first before saving in store. Have a look at https://github.com/yury-dymov/json-api-normalizer |
Right, I'm using the {
users: {
'1': {
id: '1',
attributes: {},
relationships: {
books: {
data: {
[{
id: '1',
type: 'books'
}, {
id: '2',
type: 'books'
}]
}
}
}
}
},
books: {}
} My point is that if I've just made a request like console.log(user.books);
// output
[{
id: '1',
type: 'books'
}, {
id: '2',
type: 'books'
}] |
Here's the diff of my changes: JakeDluhy@aa76ec0, to help you understand what I'm talking about |
oh, now I see. Yeah, feel free to submit PR, I am happy to merge it |
Thanks! Btw, I'm loving this library (and |
Thank you for your contribution and kind words :) |
If I have
users
that have manybooks
, and I make a request for auser
object without sideloading the related books, then I might have the following structure in my store:If I run
const user = build(state.entities, 'users', '1')
then I get the user back. However if I then runuser.books
I get[null, null]
. I would expect that I should getI have experienced many use cases where I don't need the full related object, just the id (to provide a link to that object, for instance) and so I won't
include
the related resources.I'd be happy to make the changes if you would accept a PR!
The text was updated successfully, but these errors were encountered: