// import the required GraphQL Types
const {
    GraphQLObjectType,
    GraphQLInt,
    GraphQLString,
    GraphQLList,
    GraphQLID
  } = require('graphql');
  
var GraphQLDate = require('graphql-date')  
  
const  db  = require('../../models');
const Ad = db.ads;

const questionType = new GraphQLObjectType({
    name: 'Question',
    description: 'A question',
    fields: () => ({
        username:{
            type: GraphQLString
        },
        question:{
            type: GraphQLString
        },
        reponse:{
            type: GraphQLString
        }
    })
})


const AdType = new GraphQLObjectType({
  name: 'Ad',
  description: 'This represents a Ad',
  // all the fields a Ad can have
  fields: () => ({
      
          id: {
              type: GraphQLID
          },
          titre: {
              type: GraphQLString
          },
          slug: {
            type: GraphQLString
        },
        type: {
            type: GraphQLString
        },
        statusPublication: {
            type: GraphQLString
        },
        statusBien: {
            type: GraphQLString
        },
        description: {
            type: GraphQLString
        },
        prix: {
            type: GraphQLInt
        },
        //error
        date: {
            type: GraphQLDate
        },
        images:{
            type: GraphQLList(GraphQLString)
        },
        id_user : {
            type: GraphQLString
          },     
        questions: {
            type: GraphQLList(questionType)
        }
      
  })
 });
  
  module.exports =  AdType