title: Ember: Relationship link related data not loading / disappearing
body: <p>I'm experiencing somewhat of a bug with Ember/Ember-data. Here's my scenario:</p>
  
  <ol>
  <li><p>Client lands on <code>/</code> route and Ember loads data from <code>/api/v1/videos?limit=8</code>. The response comes from a rails-api backend using <a href="https://github.com/rails-api/active_model_serializers" rel="nofollow noreferrer">active_model_serializers</a> which ensures the response is JSON API compliant. Now the store has 8 arbitrary videos loaded into it.</p></li>
  <li><p>Each video component in the DOM has a link to a user page (the video <code>belongsTo</code> a user and a user <code>hasMany</code> videos). </p></li>
  <li><p>Client clicks on a <code>link-to</code> which navigates to <code>/users/1</code> which represents a user with ID 1</p></li>
  <li><p>The model hook for that route just loads a single user record. The user record has the following payload:</p></li>
  </ol>
  
  <blockquote>
  <pre><code>{
      "data": {
          "id": "1",
          "relationships": {
              "videos": {
                  "data": [],
                  "links": {
                      "related": "/api/v1/videos?user_id=1"
                  }
              },
          },
          "type": "users"
      }
  }
  </code></pre>
  </blockquote>
  
  <p>The problem is that ember does not automatically send the request for <code>/api/v1/videos?user_id=1</code> (presumably because a similar request <code>/api/v1/videos?limit=8</code> already happened).</p>
  
  <p>If I directly load the <code>/users/1</code> page then Ember is smart and auto-loads data from the <code>/api/v1/videos?user_id=1</code> endpoint.</p>
  
  <p>I suspect that Ember is being fooled by the fact that a similar request to the videos endpoint already happened with different query parameters. The end result is that my app does not show any data on the user page.</p>
  
  <p>One way to fix this is to not use the links/related syntax but populate <code>"data": [],</code> with video IDs which will cause ember to send n requests for n videos. This works but is not acceptable for a large scale app where a user page might have hundreds of videos.</p>
  
  <p>How can I fix this?</p>
  
  <p>You can see that the active_model_serializers setup for the links/related structure is supposed to be <a href="https://github.com/rails-api/active_model_serializers/blob/v0.10.6/docs/howto/add_relationship_links.md#links-that-follow-the-jsonapi-spec" rel="nofollow noreferrer">tailored specifically for ember-data</a>.</p>
  
  <hr>
  
  <p>Edit: I tried getting rid of <code>data: []</code> using <a href="https://github.com/rails-api/active_model_serializers/pull/1454" rel="nofollow noreferrer"><code>include_data false</code></a> in active_model_serializers which didn't help.</p>
  
  <hr>
  
  <p>Edit 2: Here's the payload of <code>/api/v1/videos?limit=8</code>:</p>
  
  <pre><code>{
      "data": [
          ...
          {
              "attributes": {
                  ...
              },
              "id": "325",
              "relationships": {
                  "user": {
                      "data": {
                          "id": "1",
                          "type": "users"
                      }
                  }
              },
              "type": "videos"
          },
          ...
      ]
  }
  </code></pre>
  
  <p>In other words, some of the videos in that payload <em>may</em> belong to the user we will later load.</p>
  
  <hr>
  
  <p>Edit 3: I'm doing this as a workaround in the user route:</p>
  
  <pre><code>afterModel(user) {
    user.hasMany('videos').reload();
  })
  </code></pre>
  
  <p>It's kind of dumb but it gets the job done for now.</p>
  
  <hr>
  
  <p>Edit 4: I've tried upgrading to ember and ember-data v3. The behavior persists.</p>