-
Notifications
You must be signed in to change notification settings - Fork 642
Closed
Labels
Milestone
Description
As of now, when defining a relationship in a Model class, the documentation states this :
// The related model. This can be either a Model
// subclass constructor or an absolute file path
// to a module that exports one. We use the file
// path version in this example to prevent require
// loops.Setting a string pointing to the file where the dependant model feels more like a workaround than a proper solution.
I've seen this issue tackled in graphql-js using thunks. See here : graphql/graphql-js#373
My proposal is to allow the developer to write this :
import RelationModel from './RelationModel';
export default class MyModel extends Model {
/* ... */
static relationMappings = {
relation: {
modelClass: () => RelationModel,
},
};
}freddi301, vjpr, capaj and demisx