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

hasMany resolution will not use related links if any data:[] is present #4712

Closed
rstudner opened this issue Dec 13, 2016 · 2 comments · Fixed by #5410
Closed

hasMany resolution will not use related links if any data:[] is present #4712

rstudner opened this issue Dec 13, 2016 · 2 comments · Fixed by #5410

Comments

@rstudner
Copy link

If I have this json-api response:

{
  "data": [
    {
      "type": "expel-alerts",
      "id": "64839987-80d5-4de7-9a74-62d472ba0562",
      "attributes": {
        "detail": "collaborate with collaborators",
        "title": "3 endpoints in Finance domain beaconing to known C2 122.33.52.122",
        "severity": "3",
        "activity-start": "2016-11-23T04:55:45.000Z",
        "activity-end": "2016-11-25T23:55:45.000Z",
        "type": "network"
      },
      "relationships": {
        "vendor-alerts": {
          "data": [
            {
              "type": "vendor-alerts",
              "id": "a91db472-99f7-4a8d-8878-7365e689a346"
            }
          ],
          "links": {
            "self": "/expel-alerts/64839987-80d5-4de7-9a74-62d472ba0562/relationships/vendor-alerts",
            "related": "/expel-alerts/64839987-80d5-4de7-9a74-62d472ba0562/vendor-alerts"
          }
        }
      }
    }
  ],
  "meta": {
    "count": 1
  }
}

In the ember inspector if $E is set to the expelAlert model object, , if I do $E.get('vendorAlerts') , ember-data will attempt to do /api/vendor-alerts/a91db472-99f7-4a8d-8878-7365e689a346 to retrieve the vendorAlert model (ignoring the related links entry)

If, the JSONAPI response (for just the relationships area) is:

      "relationships": {
        "vendor-alerts": {
          "links": {
            "self": "/expel-alerts/64839987-80d5-4de7-9a74-62d472ba0562/relationships/vendor-alerts",
            "related": "/expel-alerts/64839987-80d5-4de7-9a74-62d472ba0562/vendor-alerts"
          }
        }
      }

then $E.get('vendorAlerts') will hit /api/expel-alerts/64839987-80d5-4de7-9a74-62d472ba0562/vendor-alerts (respecting the related links entry)

I would think(?) it would always prioritize the links entry. (especially if there were say, 5000 vendor-alerts.. you wouldn't want 5000 individual ajax requests, nor would the coalesce true ?filter[etc]=1,2,...,5000 be right either)

@runspired
Copy link
Contributor

Related: #4292 (comment)

@runspired
Copy link
Contributor

Tangential: #2162

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

Successfully merging a pull request may close this issue.

2 participants