lib/schema/index.js
function buildSchema(models, typeMap) {
  let type;

  var _models$map$reduce = models.map(model => {
    type = typeMap[model.modelName];
    return {
      query: (0, _buildQuery2.default)(model, type),
      mutation: (0, _buildMutation2.default)(model, type)
    };
  }).reduce((fields, modelField) => {
    fields.query = (0, _assign2.default)({}, fields.query, modelField.query);
    fields.mutation = (0, _assign2.default)({}, fields.mutation, modelField.mutation);
    return fields;
  }, { query: {}, mutation: {} });

  const query = _models$map$reduce.query;
  const mutation = _models$map$reduce.mutation;


  return {
    query: query,
    mutation: mutation
  };
}
function buildSchema(models, typeMap) {
  let type;

  var _models$map$reduce = models.map(model => {
    type = typeMap[model.modelName];
    return {
      query: (0, _buildQuery2.default)(model, type),
      mutation: (0, _buildMutation2.default)(model, type)
    };
  }).reduce((fields, modelField) => {
    fields.query = (0, _assign2.default)({}, fields.query, modelField.query);
    fields.mutation = (0, _assign2.default)({}, fields.mutation, modelField.mutation);
    return fields;
  }, { query: {}, mutation: {} });

  const query = _models$map$reduce.query;
  const mutation = _models$map$reduce.mutation;


  return {
    query: query,
    mutation: mutation
  };
}
function buildSchema ( models , typeMap ) { let type ; var _models$map$reduce = models . map ( model => { type = typeMap [ model . modelName ] ; return { query : ( 0 , _buildQuery2 . default ) ( model , type ) , mutation : ( 0 , _buildMutation2 . default ) ( model , type ) } ; } ) . reduce ( ( fields , modelField ) => { fields . query = ( 0 , _assign2 . default ) ( { } , fields . query , modelField . query ) ; fields . mutation = ( 0 , _assign2 . default ) ( { } , fields . mutation , modelField . mutation ) ; return fields ; } , { query : { } , mutation : { } } ) ; const query = _models$map$reduce . query ; const mutation = _models$map$reduce . mutation ; return { query : query , mutation : mutation } ; }
Build graphql CRUD schema based on models and types
@params
- models {Array} mongoose models
- typeMap {Object} map of model and corresponding graphql type
@return
- grapqhl schema which has query and mutation
Build graphql CRUD schema based on models and types