-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
DS.Snapshot.belongsTo()
does not abide by the documented API
#7040
Comments
The problem here seems to be that we do not handle meta in top level objects. The top-level object coming from
I can look into this at some point. |
The bug here is because |
I think the fix is likely something in |
@snewcomer We do actually handle top level links and meta for this case in theory, I suspect meta not working may be related to not handling |
This may be at least partially fixed on master, @Herriau could you PR a test? |
Description
When an optional
belongsTo
relationship is loaded independently from the model it's defined on, e.g. when invokingawait someRecord.belongsTo('someRel').load()
, and the response is{ "data": null }
thenDS.Snapshot.belongsTo()
for that relationship returnsundefined
instead ofnull
.Say I have a first record loaded through
store.findRecord('some-model', 1, { include: 'some-rel' })
, intially hydrated from the following JSONAPI document:And another one loaded through
store.findRecord('some-model', 2)
(note the lack of include), intially hydrated from the following JSONAPI document:The
someRel
relationship is already loaded on ID=1 (by way of?include
), however it's not initially loaded on ID=2, but let's say I load that one relationship separately withawait record.belongsTo('someRel').load()
, and let's say the request / response that resulted from that call looks like:Suppose now I have a custom serializer for
some-model
:Then we can observe the following:
The API doc for
DS.Snapshot.belongsTo()
states:So I would have expected both calls to return
null
, since both fall under the "known but unset" case.Versions
The text was updated successfully, but these errors were encountered: