<commit_before>import * as typeMapper from './typeMapper';
import { GraphQLNonNull, GraphQLEnumType } from 'graphql';
import { globalIdField } from 'graphql-relay';

module.exports = function (Model, options) {
  options = options || {};

  var result = Object.keys(Model.rawAttributes).reduce(function (memo, key) {
    if (options.exclude && ~options.exclude.indexOf(key)) return memo;
    if (options.only && !~options.only.indexOf(key)) return memo;

    var attribute = Model.rawAttributes[key]
      , type = attribute.type;

    // determine the key
    var mappedKey = key;
    if (options.map) {
      if (typeof options.map === 'function') {
        mappedKey = options.map(key);
      } else {
        mappedKey = options.map[key] || key;
      }
    }

    memo[mappedKey] = {
      type: typeMapper.toGraphQL(type, Model.sequelize.constructor)
    };

    if (memo[mappedKey].type instanceof GraphQLEnumType ) {
      memo[mappedKey].type.name = `${Model.name}${mappedKey}EnumType`;
    }

    if (attribute.allowNull === false || attribute.primaryKey === true) {
      memo[mappedKey].type = new GraphQLNonNull(memo[mappedKey].type);
    }

    return memo;<commit_msg>remove redundant variable, and ignore falsy return values from the map function<commit_after>import * as typeMapper from './typeMapper';
import { GraphQLNonNull, GraphQLEnumType } from 'graphql';
import { globalIdField } from 'graphql-relay';

module.exports = function (Model, options) {
  options = options || {};

  var result = Object.keys(Model.rawAttributes).reduce(function (memo, key) {
    if (options.exclude && ~options.exclude.indexOf(key)) return memo;
    if (options.only && !~options.only.indexOf(key)) return memo;

    var attribute = Model.rawAttributes[key]
      , type = attribute.type;


    if (options.map) {
      if (typeof options.map === 'function') {
        key = options.map(key) || key;
      } else {
        key = options.map[key] || key;
      }
    }

    memo[key] = {
      type: typeMapper.toGraphQL(type, Model.sequelize.constructor)
    };

    if (memo[key].type instanceof GraphQLEnumType ) {
      memo[key].type.name = `${Model.name}${key}EnumType`;
    }

    if (attribute.allowNull === false || attribute.primaryKey === true) {
      memo[key].type = new GraphQLNonNull(memo[key].type);
    }

    return memo;
{'fraction_non_alphanumeric': 0.1430401366353544, 'fraction_numerical': 0.0, 'mean_word_length': 3.252268602540835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5734728', 'n_tokens_mistral': 736, 'n_tokens_neox': 727, 'n_words': 161}