
// Define the Feathers schema for service `<%= serviceName %>`. (Can be re-generated.)
<% __defaultGraphqlName = serviceName.charAt(0).toUpperCase() + serviceName.slice(1) -%>
<%- insertFragment('imports') %>
<%- insertFragment('init') %>

// Define the model using JSON-schema
let schema = {
  <%- insertFragment('schema_header', [
    `  title: '${__defaultGraphqlName}',`,
    `  description: '${__defaultGraphqlName} database.',`,
  ]) %>
  <%- insertFragment('schema_definitions') %>

  // Required fields.
  required: [
    <%- insertFragment('schema_required') %>
  ],
  // Fields with unique values.
  uniqueItemProperties: [
    <%- insertFragment('schema_unique') %>
  ],

  // Fields in the model.
  properties: {
    <%- insertFragment('schema_properties') %>
  },
  <%- insertFragment('schema_more') %>
}<%- sc %>

// Define optional, non-JSON-schema extensions.
let extensions = {
  // GraphQL generation.
  graphql: {
    <%- insertFragment('graphql_header', [
      `    name: '${serviceNameSingular.charAt(0).toUpperCase() + serviceNameSingular.slice(1)}',`,
      '    service: {',
      `      sort: { ${primaryKey.idName}: 1 },`,
      '    },',
      '    // sql: {',
      `    //   sqlTable: '${__defaultGraphqlName}',`,
      `    //   uniqueKey: \'${primaryKey.idName}\',`,
      '    //   sqlColumn: {',
      '    //     __authorId__: \'__author_id__\',',
      '    //   },',
      '    // },',
    ], true) %>
    discard: [
      <%- insertFragment('graphql_discard') %>
    ],
    add: {
      <%- insertFragment('graphql_add', [
        `      // __author__: { type: '__User__!', args: false, relation: { ourTable: '__authorId__', otherTable: '${primaryKey.idName}' } },`,
      ])%>
    },
    <%- insertFragment('graphql_more') %>
  },
}<%- sc %>

<%- insertFragment('more') %>

let moduleExports = {
  schema,
  extensions,
  <%- insertFragment('moduleExports') %>
}<%- sc %>

<%- insertFragment('exports') %>
<%- `${tplExport('moduleExports')}${sc}` %>

<%- insertFragment('funcs') %>
<%- insertFragment('end') %>
