const {
    GraphQLSchema,
    GraphQLObjectType,
    GraphQLList
  } = require('graphql');
  
const AdType = require('./types/adType')
const Queries = require('./queries/adQuery')
const AdMutations = require('./queries/adMutations')
const UsersQuery = require('./queries/userQuery')
const UserMutations = require('./queries/userMutations')

const RootQuery = new GraphQLObjectType({
  name: 'rootQuery',
  description: 'This is the root query which holds all possible READ entrypoints for the GraphQL API',
  fields: () => ({
    ads : Queries.AdsQuery,
    ad :  Queries.AdQuery,
    users : UsersQuery.Users
  }),
});

const RootMutation = new GraphQLObjectType({
  name: 'rootMutation',
  description: 'This is the root query which holds all possible READ entrypoints for the GraphQL API',
  fields: () => ({
    adDelete : AdMutations.deleteAdMutation,
    adCreate : AdMutations.createAdMutation,
    adUpdate : AdMutations.updateAdMutation,
    register : UserMutations.createUserMutation
  }),
});



const schema = new GraphQLSchema({
  query: RootQuery,
  mutation: RootMutation
});


module.exports =  schema 