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] ED doesn't consider links in the compound documents #5062

Closed
lancedikson opened this issue Jul 12, 2017 · 3 comments
Closed

[JSON API] ED doesn't consider links in the compound documents #5062

lancedikson opened this issue Jul 12, 2017 · 3 comments

Comments

@lancedikson
Copy link

It seems that ED doesn't recognize links when data exists as well in the response from the server. The example of a buggy response from server:

{
  "data": {
  	...
  },
  "included": [
    {
      "type": "blog-posts",
      "id": "1",
      "attributes": {
        "title": "Lorem"
      },
      "relationships": {
        "comments": {
          "links": {
            "related": "/api/blog-posts/1/comments"
          },
          "data": [
            {
              "type": "comments",
              "id": "1"
            },
            {
              "type": "comments",
              "id": "2"
            },
            {
              "type": "comments",
              "id": "3"
            }
          ]
        }
      }
    }
  ]
}

In that case, ED is trying to send requests to /api/comments/1 ignoring the links.related attribute. But, seems that it should recognize that kind of links according to the specification. Also, I created a discussion on the JSON API forum.

lancedikson added a commit to lancedikson/ember-cli-mirage that referenced this issue Jul 12, 2017
For the sake of temporary avoiding of the issue when ED doesn't recognize both `links` and `data` inside of `included` property (emberjs/data#5062)
@stefanpenner
Copy link
Member

This seems quite close to the test scenario provided in #5147 can you confirm that is the same scenario? If so, #5147 fixes it. If not, if you can provide a failing test, I can investigate.

@andrewfan
Copy link
Contributor

Hey, @stefanpenner @lancedikson, I think links.related still does not work, I did not check the whole flow of serialization to understand if links from response are properly stored somewhere, but I checked https://github.com/emberjs/data/blob/master/addon/-private/adapters/build-url-mixin.js#L55. buildURL method is called for every API operation and it does not have any logic for handling links. @stefanpenner do you know if this feature will be supported in the near future?

@runspired
Copy link
Contributor

This is resolved by #5410 🎉

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