mardi 22 août 2017

Maximum Call Stack Size Exceeded Ember Mirage CLI

I am working with Ember 2.0, and I'm trying to correctly set up a many to one relationship with my model. I am using ember-mirage-cli to simulate the backend, and send me data. I have been struggling with this for quite some time, and looked at the marked issues on the ember-cli-mirage github. I saw similar issues that were marked as resolved, but no one posted a direct answer on how to fix this error. I was hoping someone on here could point out the error that I have in my setup... It is currently complaining about a Maximum Call Stack Size Exceeded.

app/models/parent.js

import DS from 'ember-data';

export default DS.Model.extend({
    childEntries : DS.hasMany('child-entry'),
});

app/models/child-entry.js

import DS from 'ember-data';

export default DS.Model.extend({
    parent: DS.belongsTo('parent')
});

mirage/models/parent.js

import { Model, hasMany } from 'ember-cli-mirage';

export default Model.extend({
    childEntries: hasMany('child-entry'),
});

mirage/models/child-entry.js

import { Model, belongsTo } from 'ember-cli-mirage';

export default Model.extend({
    parent: belongsTo()
});

mirage/scenarios/default.js

export default function(server) {
  server.create('parent', 'withGeneratedChildren');
}

mirage/factories/parent.js

import Mirage, { Factory, faker, hasMany, trait } from 'ember-cli-mirage';

export default Mirage.Factory.extend({
    childEntries: hasMany('child-entry'),

    withGeneratedChildren: trait({
        afterCreate(parent, server) {
            parent.update({
                childEntries: server.createList('childEntry', 10, {parent: parent})
            });
        }
    }),
});

mirage/factories/child-entry.js

import Mirage, { faker, association, trait } from 'ember-cli-mirage';

export default Mirage.Factory.extend({
    parent: association()
});




Aucun commentaire:

Enregistrer un commentaire