title: How to seed models with polymorphic one to one relationship in mirage js?
body: <p>this is just an example, I understand that you would normally have multiple comments, but for the sake of this example, lets assume that we have</p>
  <p>following models:</p>
  <pre><code> models: {
      blogPost: Model.extend({
        comment: belongsTo(),
      }),
  
      picture: Model.extend({
        comment: belongsTo(),
      }),
  
      comment: Model.extend({
        commentable: belongsTo({ polymorphic: true }),
      }),
    },
  </code></pre>
  <p>and following factories:</p>
  <pre><code>  factories: {
      blogPost: Factory.extend({
        title: &quot;Whatever&quot;,
        withComment: trait({
          comment: association(),
        }),
    }),
  </code></pre>
  <p>Now when trying to seed server with:</p>
  <pre><code>seeds(server) {
    server.create(&quot;blogPost&quot;, &quot;withComment&quot;);
  }
  </code></pre>
  <p>It does seed it but when checking <code>console.log(server.db.dump());</code> the commentable is null... <code>commentableId: null</code>.</p>
  <p><a href="https://i.stack.imgur.com/Et6tr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Et6tr.png" alt="enter image description here" /></a></p>
  <p>Why?</p>
  <p><strong>EDIT:</strong></p>
  <p>This is a tricky one. I changed</p>
  <pre><code>comment: Model.extend({
    commentable: belongsTo({ polymorphic: true }),
  }),
  </code></pre>
  <p>to:</p>
  <pre><code>comment: Model.extend({
    blogPost: belongsTo({ polymorphic: true }),
  }),
  </code></pre>
  <p>just to see if <code>commentable</code> part is causing the issue. This time I got a different error:
  <code>Mirage: You're using the association() helper on your comment factory for blogPost, which is a polymorphic relationship. This is not currently supported.&quot;</code></p>
  <p>So, it is currently not possible to use <code>association()</code> on polymorphic relationship. I wish this was announced in documentation...</p>
  <p>Still, I cannot find a way to seed it even without shorthand <code>association()</code>.</p>