CodeYellowBV/mobx-spine

Withing relation with backendResourceName

Closed this issue · 2 comments

I have an Order which has an OrderContainer. On OrderContainer I have defined:

static backendResourceName = 'order_container';

Now I want to fetch an existing order with its container:

const order = new Order({ id }, { relations: ['orderContainer'] });

The url becomes:

api/order/15/?with=orderContainer

but I expect:

api/order/15/?with=order_container

Okay, fair point. I took a look if I could implement this quickly, but it turns out to be a little more difficult since I need to traverse all (nested) relations to get their backendResourceName. As long as this is a model, it's easy (e.g. animal.farm.owner), but for a model in a store this is more difficult (animal.owners.location).

On second thought, we can fix your specific issue without having to use backendResourceName. The automatic camelCase -> snake_case should also be used in the with because we use it for relations too.