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

JSONSerializer does not push payload's included records into the store #3549

Closed
tstirrat opened this issue Jul 15, 2015 · 4 comments
Closed

Comments

@tstirrat
Copy link
Contributor

I am using DS.JSONSerializer with DS.EmbeddedRecordsMixin while trying to get emberfire compatible with 1.13.x (FirebaseExtended/emberfire#283).

The embedded records are being correctly extracted into the JSON-API included property, but they are not being pushed into the store. This results in the error:

You looked up the 'posts' relationship on a 'author' with id author_1 but some of the associated records were not loaded.

Initial payload given to serializer.normalize:

{
  "id": "author_1",
  "name": "Tim",
  "posts": [
    {
      "id": "post_1",
      "title": "Post 1"
    }
  ]
}

Serializer normalizes this into:

{
  "data": {
    "id": "author_1",
    "type": "author",
    "attributes": {
      "name": "Tim"
    },
    "relationships": {
      "posts": {
        "data": [
          {
            "id": "post_1",
            "type": "post"
          }
        ]
      }
    }
  },
  "included": [
    {
      "id": "post_1",
      "type": "post",
      "attributes": {
        "title": "Post 1"
      },
      "relationships": {}
    }
  ]
}

Here is a minimal test to show you what is happening:

http://jsfiddle.net/3eff3bsz/

The culprit is _normalizeResponse #443 not passing through the included property.

I'm willing to make a PR for this but do I branch off the release branch to get it into 1.13.x?

@bmac
Copy link
Member

bmac commented Jul 15, 2015

Hi @tstirrat. Thanks for tracking down the issue. Go ahead and open a pr against the master branch and prefix your commit message with [BUGFIX release], then the Ember Data team will cherry-pick the commit onto the release branch.

@tstirrat
Copy link
Contributor Author

ok, thanks, will do

@wecc
Copy link
Contributor

wecc commented Jul 15, 2015

Thanks for the issue @tstirrat!

This is indeed a bug and should be easily solved by take included into account here and here.

(Like we do here)

@fivetanley
Copy link
Member

closed via #3550

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

4 participants