{"size": 745, "ext": "js", "max_stars_repo_path": "src/modules/core/api/graphql/type-defs/fields.js", "max_stars_repo_name": "tsithu/kako", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/modules/core/api/graphql/type-defs/fields.js", "max_issues_repo_name": "tsithu/kako", "max_issues_repo_issues_event_min_datetime": "2020-06-13T02:37:16.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-03T17:08:20.000Z", "max_forks_repo_path": "src/modules/core/api/graphql/type-defs/fields.js", "max_forks_repo_name": "tsithu/kako", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 9, "max_forks_count": null, "avg_line_length": 28.6538461538, "max_line_length": 75, "alphanum_fraction": 0.5865771812}
import _ from 'lodash'

export default modules => modules.map(({ model }) => {
  const {
    modelName, fields, fieldsWithRelation, gqlSchema, skipDefaultCRUDSchema
  } = model
  const gqlDirective = (() => {
    if (gqlSchema) {
      const { directive } = gqlSchema
      if (directive) {
        return `${_.isFunction(directive) ? directive() : directive} `
      }
    }
    return ''
  })()
  const strBuffer = skipDefaultCRUDSchema !== true ? [
    `type ${modelName} implements Node ${gqlDirective}{`,
    '  nodeId: ID!',
    ...fields.map(f => `  ${f.gqlFieldDef} ${f.gqlDirective}`),
    ...fieldsWithRelation.map(f => `  ${f.gqlFieldDef}`),
    '}\n'
  ] : []
  // $logger.info(strBuffer.join('\n'))
  return strBuffer.join('\n')
})
