title: Limiting lazy loaded associations in Sequelize
body: <p>I'm using <a href="https://sequelize.org/v5/" rel="nofollow noreferrer">Sequelize 5</a> as an ORM for my GraphQL API but I've run into a performance issue when querying associated data.</p>
  
  <p>Let's say I have a <code>User</code> which has many <code>Post</code>s, so my model definitions look like this:</p>
  
  <pre><code>class User extends Model { }
  User.init({ name: Sequelize.STRING }, { sequelize });
  
  class Post extends Model { }
  Post.init({ content: Sequelize.STRING }, { sequelize });
  
  User.hasMany(Post);
  </code></pre>
  
  <p>Now I have fetched a <code>User</code> model from the database and I want to query an <code>x</code> amount of posts from this user. I know I can fetch all posts using <code>user.getPosts()</code>, but that would return way more records than I need.</p>
  
  <p>I have found <a href="https://stackoverflow.com/a/52102890/4136777">this answer</a> which explains how to apply a limit when <em>eager loading</em> the relation using the <code>include</code> option, but in my case I would like to <em>lazy load</em> the relation. The reason for this is because of how GraphQL resolvers work.</p>
  
  <p><strong>So my question is:</strong> How do I get the first <code>x</code> posts of a user?</p>