const {
    GraphQLInt,
    GraphQLString,
    GraphQLList,
    GraphQLObjectType,
    GraphQLID,
  } = require('graphql');
  
//   const { AdType } = require('../types/adType');
const  db  = require('../../models');

const Ad = db.ads;
const AdType = require('./../types/adType')  

//Return All the ads
exports.AdsQuery = {
    type : GraphQLList(AdType),
    description: 'Return All the ads',
    resolve: async () => await Ad.find({})
}; 

//return one Ad
exports.AdQuery = {
    type : AdType,
    description: 'Return one Ad',
    args:{
        id : {
            type:GraphQLID
        }
    },
    resolve: async (parent, args ) => await Ad.findById(args.id).exec()
}; 
  