import { BaseGraphqlModule } from '#services/Graphql/util/BaseGraphqlModule'
import { HttpContext } from '@adonisjs/core/http'

import {{modelName}} from '#app/models/{{modelName}}'

export default class {{modelName}}Module extends BaseGraphqlModule {

  public scopes: Array<string> = ['admin', 'user', 'general', 'client']
    
  constructor(scope: string) {
    super('{{modelName}}', {{modelName}})
    this.scope = scope
    this.boot()
  }

  public attributes = [
    {{#each fields}}
    this.addAttribute('{{this.name}}', BaseGraphqlModule.TYPES.{{this.GRAPHQL_MODULES_type}}),
    {{/each}}

    // {
    //   name: 'example',
    //   type: 'Example',
    //   scopes: ['admin', 'user', 'client'],
    //   handler: async (parent: {{modelName}}, args: any, _context: HttpContext) => {
    //     return await this.fetchData({ query: parent.related('chat').query(), args, single: true })
    //   }
    // },
    
  ]

  public queries = [
    // {
    //   name: 'message',
    //   type: '{{modelName}}',
    //   params: [
    //     this.args.findOne
    //   ],
    //   handler: async (_parent: any, args: any, _context: HttpContext) => {
    //     return this.fetchData({ query: {{modelName}}.query(), args, single: true })
    //   }
    // },
  ]
}