Support Topics Documentation Slack YouTube Blog

REST loadRelations not working


(David M) #1

I have a model which has three relation properties (all the same type). Eg.
Thread

    user1 user2 lastUser
I have seen that if the "loadRelations" arg on a Thread request is "loadRelations=userA,userB,lastUser", then userA will not fully load (only "__originSubID" is populated), whereas if the arg is "loadRelations=userB,lastUser, userA" then all properties will load. I have confirmed this on the REST console. Is there something wrong to cause the difference?

(Mark Piller) #2

This does not sound right. I’d like to see it in your app. What is your application ID?

Regards,
Mark


(David M) #3

Application ID is 85861D3C-D0D4-762E-FFAE-4196C3F01A00. For reference, here are two calls which produce different results:

https://api.backendless.com/development/data/Connection?pageSize=1&loadRelations=userA%2CuserB%2ClastActor

https://api.backendless.com/development/data/Connection?pageSize=1&loadRelations=userB%2ClastActor%2CuserA

It also seems to be affected by toggling autoload on user.profilePhoto property.


(Mark Piller) #4

Hi David,

I was able to run both queries and observe the same result. You’re right that the responses are different, although technically the result is correct (from the backendless’ serializer perspective)…

When you see a JSON object with the “__originSubID” element, it is essentially a pointer to another entity in the same response. In order to find that entity, you look for an object that contains “__subID” with the same value. In your case, both “userA” and “lastActor” are going to be the same objects, therefore for one of the responses you will see the userA objects serialized through a pointer. What I still need to figure out is why the order of the properties in the request makes the difference on how the objects are serialized back in the response.

Hope this helps.

Regards,
Mark