import { GraphQLError } from 'graphql';
import { ChargesMatcherProvider } from '../providers/charges-matcher.provider.js';
export const findChargeMatchesResolver = {
    Query: {
        findChargeMatches: async (_, { chargeId }, { injector }) => {
            try {
                const result = await injector.get(ChargesMatcherProvider).findMatchesForCharge(chargeId);
                return result;
            }
            catch (e) {
                if (e instanceof GraphQLError) {
                    throw e;
                }
                const message = e?.message ??
                    e?.errors.map(e => e.message).toString() ??
                    'Unknown error';
                throw new GraphQLError(message);
            }
        },
    },
};
//# sourceMappingURL=find-charge-matches.resolver.js.map