datasource/*: code a little clean up

pull/14/head
leonnicolas 4 years ago
parent 45a7fa6ec7
commit a67c0ff659
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -134,7 +134,6 @@ export class CargoBikeAPI extends DataSource {
*/
async createCargoBike ({ cargoBike }: { cargoBike: any }) {
let inserts: any;
try {
await this.connection.transaction(async (entityManager:any) => {
inserts = await entityManager.getRepository(CargoBike)
.createQueryBuilder('cargobike')
@ -153,10 +152,6 @@ export class CargoBikeAPI extends DataSource {
.of(inserts.identifiers[0].id)
.add(cargoBike.equipmentTypeIds);
});
} catch (e: any) {
console.log(e);
return new GraphQLError('Transaction could not be completed');
}
const newbike = inserts.generatedMaps[0];
newbike.id = inserts.identifiers[0].id;
return newbike;

@ -105,7 +105,6 @@ export class ContactInformationAPI extends DataSource {
.select()
.where('ci."personId" = :id', { id: id })
.getMany();
console.log(res);
return res;
}

@ -176,7 +176,6 @@ export class LendingStationAPI extends DataSource {
.where('timeframe."cargoBikeId" = :id', { id: timeFrame.cargoBikeId })
.andWhere('timeframe."dateRange" && :tr', { tr: timeFrame.dateRange })
.getMany();
console.log(overlapping);
if (overlapping.length !== 0) {
throw new UserInputError('TimeFrames with ids: ' + overlapping.map((e) => { return e.id + ', '; }) + 'are overlapping');
}
@ -198,7 +197,6 @@ export class LendingStationAPI extends DataSource {
.set(timeFrame.lendingStationId);
});
} catch (e) {
console.log(e);
if (e instanceof UserInputError) {
return e;
} else if (e instanceof QueryFailedError) {

@ -29,7 +29,6 @@ export class ProviderAPI extends DataSource {
async createProvider (provider: any) {
let inserts: any;
try {
await this.connection.transaction(async (entityManager: any) => {
inserts = await entityManager.getRepository(Provider)
.createQueryBuilder('provider')
@ -48,10 +47,7 @@ export class ProviderAPI extends DataSource {
.of(inserts.identifiers[0].id)
.add(provider.contactPersonIds);
});
} catch (e: any) {
console.log(e);
return new GraphQLError('Transaction could not be completed');
}
const ret = inserts.generatedMaps[0];
ret.id = inserts.identifiers[0].id;
return ret;

@ -40,7 +40,6 @@ export default {
ContactInformation: {
person: (parent: any, __: any, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadPerson)) {
console.log(parent);
return dataSources.contactInformationAPI.personByContactInformationId(parent.id);
} else {
return new GraphQLError('Insufficient Permissions');

Loading…
Cancel
Save