BlairAllegroTech / js-data-jsonapi

JsonApi Adapter for js-data
MIT License
15 stars 5 forks source link

Revert Breaks $_JSONAPIMETA_ #36

Open rgant opened 7 years ago

rgant commented 7 years ago

Calling DS#revert on a js-data-jsonapi resource reverts some of the $_JSONAPIMETA_ breaking relationships. More details to follow.

BlairAllegroTech commented 7 years ago

Glad you're back.... I must admit i haven't been working on this project but I'll start getting back into it again..

rgant commented 7 years ago

Sorry this took me a bit to get. Here is a JSON dump of the Users Resource before revert:

{
    "phone": "123",
    "type": "admin",
    "created_at": "2016-06-11T13:46:39+00:00",
    "notification_dt": null,
    "last_name": "McTesty",
    "updated_at": "2016-12-19T21:49:55+00:00",
    "email": "test.mctesty@example.com",
    "first_name": "Test",
    "title": "1321",
    "email_status": {},
    "id": "1566",
    "$_JSONAPIMETA_": {
        "selfType": "users",
        "selfLink": "/v3/users/me",
        "isJsonApiReference": false,
        "relationships": {
            "account": {
                "related": {
                    "type": "accounts",
                    "url": "/v3/users/me/account"
                }
            }
        },
        "links": {
            "self": {
                "type": "self",
                "url": "/v3/users/me",
                "meta": {}
            }
        },
        "referenceCount": 1
    }
}

And here is after revert:

{
    "phone": "123",
    "type": "admin",
    "created_at": "2016-06-11T13:46:39+00:00",
    "notification_dt": null,
    "last_name": "McTesty",
    "updated_at": "2016-12-19T21:49:55+00:00",
    "email": "test.mctesty@example.com",
    "first_name": "Test",
    "title": "1321",
    "email_status": {},
    "id": "1566",
    "$_JSONAPIMETA_": {
        "selfType": "users",
        "selfLink": "/v3/users/me",
        "isJsonApiReference": false,
        "relationships": {},
        "links": {
            "self": {
                "type": "self",
                "url": "/v3/users/me",
                "meta": {}
            }
        },
        "referenceCount": 1
    }
}

It looks like for some reason relationships is cleared.