diff --git a/lib/SchemaBuilder.js b/lib/SchemaBuilder.js index cd0e8ad..ee0d0bc 100644 --- a/lib/SchemaBuilder.js +++ b/lib/SchemaBuilder.js @@ -89,6 +89,25 @@ class SchemaBuilder { this.mutation = mutations; return this; } + + extendWithModelMutations() { + Object.values(this.models).forEach(model => { + this._typeForModel(model); + model.modelClass.GraphqlTypes = this.typeCache; + }); + let mutations = {}; + Object.values(this.models).forEach(model => { + mutations = Object.assign(mutations, model.modelClass.mutations) + }); + this.extendWithMutations( + new GraphQLObjectType({ + name: 'RootMutationType', + description: 'Domain API actions', + fields: () => mutations + }) + ); + return this; + } setBuilderOptions(options) { this.builderOptions = options;