@accounter/server
Version:
35 lines • 1.19 kB
JavaScript
import { GraphQLError } from 'graphql';
import { SortCodesProvider } from '../providers/sort-codes.provider.js';
import { commonFinancialEntityFields } from './common.js';
export const sortCodesResolvers = {
Query: {
allSortCodes: async (_, __, { injector }) => {
try {
return await injector.get(SortCodesProvider).getAllSortCodes();
}
catch (e) {
console.error('Error fetching sort codes', e);
throw new GraphQLError(e?.message ?? 'Error fetching sort codes');
}
},
},
SortCode: {
id: dbSortCode => dbSortCode.key,
name: dbSortCode => dbSortCode.name,
},
LtdFinancialEntity: {
...commonFinancialEntityFields,
},
PersonalFinancialEntity: {
...commonFinancialEntityFields,
},
TaxCategory: {
sortCode: (parent, _, { injector }) => parent?.sort_code
? injector
.get(SortCodesProvider)
.getSortCodesByIdLoader.load(parent.sort_code)
.then(sortCode => sortCode ?? null)
: null,
},
};
//# sourceMappingURL=sort-codes.resolver.js.map