@ -15,115 +15,164 @@ export default {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
return dataSources . cargoBikeAPI . getCargoBikes ( offset , limit ) ;
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
} ,
bikeEvents : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . ReadBike Event ) ) {
return dataSources . cargoBikeAPI . bikeEvents ( offset , limit ) ;
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
} ,
bikeEventById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . ReadBike Event ) ) {
return dataSources . cargoBikeAPI . findBikeEventById ( id ) ;
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
} ,
bikeEventTypeByd : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . ReadBike Event ) ) {
return dataSources . cargoBikeAPI . findBikeEventTypeById ( id ) ;
} else {
return new GraphQLError ( 'Insufficiant Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
bikeEventTypes : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBikeEvent ) ) {
return dataSources . cargoBikeAPI . bikeEventTypes ( offset , limit ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
equipment : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . Read Equipment ) ) {
return dataSources . cargoBikeAPI . getEquipment ( offset , limit ) ;
} else {
return new GraphQLError ( 'Insufficiant Permissions' ) ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
} ,
equipmentById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Read Bike ) ) {
if ( req . permissions . includes ( Permission . Read Equipment ) ) {
return dataSources . cargoBikeAPI . equipmentById ( id ) ;
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
} ,
equipmentTypes : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Read Bike ) ) {
if ( req . permissions . includes ( Permission . Read Equipment ) ) {
return dataSources . cargoBikeAPI . equipmentTypes ( offset , limit ) ;
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
} ,
equipmentTypeById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Read Bike ) ) {
if ( req . permissions . includes ( Permission . Read Equipment ) ) {
return dataSources . cargoBikeAPI . equipmentTypeById ( id ) ;
} else {
return new GraphQLError ( 'Insufficiant Permissions' ) ;
}
} ,
bikeEventTypes : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
return dataSources . cargoBikeAPI . bikeEventTypes ( offset , limit ) ;
} else {
return new GraphQLError ( 'Insufficiant Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
CargoBike : {
engagement ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . participantAPI . engagementByCargoBikeId ( offset , limit , parent . id ) ;
if ( req . permissions . includes ( Permission . ReadEngagement ) ) {
return dataSources . participantAPI . engagementByCargoBikeId ( offset , limit , parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
coordinator ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
dataSources . participantAPI . participantByCargoBikeId ( parent . id ) ;
coordinator ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) { // TODO should be done with engagements
if ( req . permissions . includes ( Permission . ReadParticipant ) ) {
return dataSources . participantAPI . participantByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
equipment ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . equipmentByCargoBikeId ( offset , limit , parent . id ) ;
if ( req . permissions . includes ( Permission . ReadEquipment ) ) {
return dataSources . cargoBikeAPI . equipmentByCargoBikeId ( offset , limit , parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
lendingStation ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . lendingStationAPI . lendingStationByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadLendingStation ) ) {
return dataSources . lendingStationAPI . lendingStationByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
bikeEvents ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . bikeEventsByCargoBikeId ( parent . id , offset , limit ) ;
if ( req . permissions . includes ( Permission . ReadBikeEvent ) ) {
return dataSources . cargoBikeAPI . bikeEventsByCargoBikeId ( parent . id , offset , limit ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } ) ,
lockedBy ( ) : any {
return null ;
} ,
timeFrames ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . lendingStationAPI . timeFramesByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadTimeFrame ) ) {
return dataSources . lendingStationAPI . timeFramesByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
equipmentType ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . equipmentTypeByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadEquipment ) ) {
return dataSources . cargoBikeAPI . equipmentTypeByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
provider ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . providerAPI . providerByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadProvider ) ) {
return dataSources . providerAPI . providerByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
Equipment : {
cargoBike ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . cargoBikeByEquipmentId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadBike ) ) {
return dataSources . cargoBikeAPI . cargoBikeByEquipmentId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } )
} ,
BikeEvent : {
cargoBike ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . cargoBikeByEventId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadBike ) ) {
return dataSources . cargoBikeAPI . cargoBikeByEventId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
bikeEventType ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . bikeEventTypeByBikeEventId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadBikeEvent ) ) {
return dataSources . cargoBikeAPI . bikeEventTypeByBikeEventId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
responsible ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . responsibleByBikeEventId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadParticipant ) ) {
return dataSources . cargoBikeAPI . responsibleByBikeEventId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
related ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . relatedByBikeEventId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadParticipant ) ) {
return dataSources . cargoBikeAPI . relatedByBikeEventId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } )
} ,
@ -160,49 +209,49 @@ export default {
}
} ,
createBikeEvent : ( _ : any , { bikeEvent } : { bikeEvent : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . WriteBike ) ) {
if ( req . permissions . includes ( Permission . WriteBike Event ) ) {
return dataSources . cargoBikeAPI . createBikeEvent ( { bikeEvent } ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
lockBikeEventById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . WriteBike ) ) {
if ( req . permissions . includes ( Permission . WriteBike Event ) ) {
return dataSources . cargoBikeAPI . lockBikeEvent ( id , req . userId ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
unlockBikeEventById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . WriteBike ) ) {
if ( req . permissions . includes ( Permission . WriteBike Event ) ) {
return dataSources . cargoBikeAPI . unlockBikeEvent ( id , req . userId ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
createEquipment : ( _ : any , { equipment } : { equipment : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Write Bike ) ) {
if ( req . permissions . includes ( Permission . Write Equipment ) ) {
return dataSources . cargoBikeAPI . createEquipment ( { equipment } ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
lockEquipmentById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Write Bike ) ) {
if ( req . permissions . includes ( Permission . Write Equipment ) ) {
return dataSources . cargoBikeAPI . lockEquipment ( id , req . userId ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
unlockEquipmentById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Write Bike ) ) {
if ( req . permissions . includes ( Permission . Write Equipment ) ) {
return dataSources . cargoBikeAPI . unlockEquipment ( id , req . userId ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
updateEquipment : ( _ : any , { equipment } : { equipment : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Write Bike ) ) {
if ( req . permissions . includes ( Permission . Write Equipment ) ) {
return dataSources . cargoBikeAPI . updateEquipment ( equipment , req . userId ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;