const countryResolvers = () => ({
    Country: {
        async states(src, args, { stateService }) {
            const criteria = { ...args.criteria, country: src.id };
            const data = await stateService.getAll({
                ...args,
                criteria,
            });
            const totalCount = await stateService.count(criteria);
            return {
                totalCount,
                data,
            };
        },
    },
    Query: {
        async countries(_, args, { countryService }) {
            return countryService.getAllWithCount(args);
        },
        country(_, { id }, { countryService }) {
            return countryService.get(id);
        },
        countryByName(_, { name }, { countryService }) {
            return countryService.getName(name);
        },
    },
    Mutation: {
        createCountry(_, { country }, { countryService }) {
            return countryService.create(country);
        },
        updateCountry(_, { id, country }, { countryService }) {
            return countryService.update(id, country, false);
        },
        deleteCountry(_, { id }, { countryService }) {
            return countryService.delete(id);
        },
    },
});export{countryResolvers};