Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {graphql} from 'graphql';
import {getTypes} from './type';
import {getSchema} from './schema';
import {getModels} from './model';
import {processId} from './query';

function _getTypes(mongooseModels) {
const graffitiModels = getModels(mongooseModels);
Expand All @@ -11,11 +12,13 @@ function _getTypes(mongooseModels) {
export default {
graphql,
getSchema,
getTypes: _getTypes
getTypes: _getTypes,
processId
};

export {
graphql,
getSchema,
_getTypes as getTypes
_getTypes as getTypes,
processId
};
6 changes: 4 additions & 2 deletions src/query/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ export default {
getListResolver,
getAddOneMutateHandler,
getUpdateOneMutateHandler,
getDeleteOneMutateHandler
getDeleteOneMutateHandler,
processId
};

export {
Expand All @@ -337,5 +338,6 @@ export {
getUpdateOneMutateHandler,
getDeleteOneMutateHandler,
getListResolver,
connectionFromModel
connectionFromModel,
processId
};
7 changes: 4 additions & 3 deletions src/schema/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {reduce, isArray} from 'lodash';
import {reduce, isArray, isFunction} from 'lodash';
import {
GraphQLList,
GraphQLNonNull,
Expand Down Expand Up @@ -222,6 +222,7 @@ function getFields(graffitiModels, {
hooks = {}, mutation = true, allowMongoIDMutation = false,
customQueries = {}, customMutations = {}
} = {}) {

const types = type.getTypes(graffitiModels);
const {viewer, singular} = hooks;

Expand Down Expand Up @@ -258,8 +259,8 @@ function getFields(graffitiModels, {
}
};
}, {
queries: customQueries,
mutations: customMutations
queries: isFunction(customQueries) ? customQueries(types) : customQueries,
mutations: isFunction(customMutations) ? customMutations(types) : customMutations
});

const RootQuery = new GraphQLObjectType({
Expand Down