Skip to content
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

JSON-API serialisation failure due to resource hash with nested data key #3381

Closed
john-griffin opened this issue Jun 18, 2015 · 5 comments
Closed

Comments

@john-griffin
Copy link

See 76cf421#commitcomment-11749944

When fetching a JSON-API 1.0 compliant resource it fails because serializer expects data to be at the top level of the resourceHash when it is actually nested in resourceHash.data.

Might be fixable by ensuring resourceHash.data is passed through here? https://github.com/emberjs/data/blob/master/packages/ember-data/lib/serializers/json-api-serializer.js#L179

@bmac
Copy link
Member

bmac commented Jun 18, 2015

@john-griffin could your share an example of your payload?

@john-griffin
Copy link
Author

@bmac here is a sample of the response

{
  "data": {
    "id": "29039571-e1f3-418c-8889-31b49951ad96",
    "type": "users",
    "links": {
      "self": "https://www.example.com/api/v3/users/29039571-e1f3-418c-8889-31b49951ad96"
    },
    "attributes": {
      "email": "foo@bar.com",
      "first-name": "Foo",
      "last-name": "Bar",
    },
    "relationships": {
      "photo": {
        "links": {
          "self": "https://www.example.com/api/v3/users/29039571-e1f3-418c-8889-31b49951ad96/relationships/photo",
          "related": "https://www.example.com/api/v3/users/29039571-e1f3-418c-8889-31b49951ad96/photo"
        },
        "data": {
          "type": "photos",
          "id": "c3412c5b-9666-413b-b6be-3c4f9988e6a5"
        }
      }
    }
  }
}

@bmac
Copy link
Member

bmac commented Jun 18, 2015

Hi @john-griffin I tried to put together a jsbin using the sample response you provided and I was unable to reproduce the error. Do you mind taking a look at it and let me know what assumption I have wrong?
http://emberjs.jsbin.com/xahori/5/edit?html,js,output

Thanks.

@john-griffin
Copy link
Author

@bmac thanks for breaking that down in a jsbin. The only difference there was ember-data version. So I upgraded from 1.13.0 to 2.0.0+canary.111a002fe4 and it was fixed. Thanks for your help!

@wecc
Copy link
Contributor

wecc commented Jun 20, 2015

For future reference: This was caused by the JSON-API adapter/serializer not opting into the new Serializer API by default. Was fixed by #3375 and in 1.13.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants