Merge branch 'main' of github.com:flotte-meets-hwr-db/apollo-server into main

pull/20/head
leonnicolas 4 years ago
commit 1545cce614

@ -26,7 +26,7 @@ import { Equipment } from '../../model/Equipment';
import { Engagement } from '../../model/Engagement';
import { Provider } from '../../model/Provider';
import { TimeFrame } from '../../model/TimeFrame';
import { ActionLogger, deleteEntity, LockUtils } from './utils';
import { ActionLogger, deleteEntity, getAllEntity, LockUtils } from './utils';
import { EquipmentType } from '../../model/EquipmentType';
import { BikeEventType } from '../../model/BikeEventType';
import { UserInputError } from 'apollo-server-express';
@ -42,14 +42,8 @@ export class CargoBikeAPI extends DataSource {
this.connection = getConnection();
}
async getCargoBikes (offset: number, limit: number) {
return await this.connection.createQueryBuilder()
.select('cargoBike')
.from(CargoBike, 'cargoBike')
.orderBy('name', 'ASC')
.offset(offset)
.limit(limit)
.getMany();
async getCargoBikes (offset?: number, limit?: number) {
return await getAllEntity(this.connection, CargoBike, 'cb', offset, limit);
}
/**
@ -221,7 +215,14 @@ export class CargoBikeAPI extends DataSource {
.loadOne();
}
async bikeEventsByCargoBikeId (id: number, offset: number = 0, limit:number = 100) {
async bikeEventsByCargoBikeId (id: number, offset?: number, limit?: number) {
if (offset === null || limit === null) {
return await this.connection.getRepository(CargoBike)
.createQueryBuilder('cb')
.relation(CargoBike, 'bikeEvents')
.of(id)
.loadMany();
} else {
return await this.connection.getRepository(CargoBike)
.createQueryBuilder('cb')
.skip(offset)
@ -230,6 +231,7 @@ export class CargoBikeAPI extends DataSource {
.of(id)
.loadMany();
}
}
async createBikeEventType (bikeEventType: any) {
return (await this.connection.getRepository(BikeEventType)
@ -267,22 +269,12 @@ export class CargoBikeAPI extends DataSource {
return await this.bikeEventTypeById(bikeEventType.id);
}
async bikeEventTypes (offset: number, limit: number) {
return await this.connection.getRepository(BikeEventType)
.createQueryBuilder('bet')
.select()
.skip(offset)
.take(limit)
.getMany();
async bikeEventTypes (offset?: number, limit?: number) {
return await getAllEntity(this.connection, BikeEventType, 'bet', offset, limit);
}
async bikeEvents (offset: number, limit: number) {
return await this.connection.getRepository(BikeEvent)
.createQueryBuilder('be')
.select()
.skip(offset)
.take(limit)
.getMany();
async bikeEvents (offset?: number, limit?: number) {
return await getAllEntity(this.connection, BikeEvent, 'be', offset, limit);
}
async bikeEventTypeById (id: number) {
@ -343,13 +335,23 @@ export class CargoBikeAPI extends DataSource {
* @param limit
* @param id
*/
async equipmentByCargoBikeId (offset: number, limit: number, id: number) {
async equipmentByCargoBikeId (id: number, offset?: number, limit?: number) {
if (offset == null || limit === null) {
return await this.connection.getRepository(Equipment)
.createQueryBuilder('equipment')
.select()
.where('equipment."cargoBikeId" = :id', { id: id })
.getMany();
} else {
return await this.connection.getRepository(Equipment)
.createQueryBuilder('equipment')
.select()
.where('equipment."cargoBikeId" = :id', { id: id })
.skip(offset)
.take(limit)
.getMany();
}
}
async createEquipment ({ equipment }: { equipment: any }) {
return await this.connection.getRepository(Equipment)

@ -21,7 +21,7 @@ import { DataSource } from 'apollo-datasource';
import { Connection, EntityManager, getConnection } from 'typeorm';
import { ContactInformation } from '../../model/ContactInformation';
import { Person } from '../../model/Person';
import { ActionLogger, deleteEntity, LockUtils } from './utils';
import { ActionLogger, deleteEntity, getAllEntity, LockUtils } from './utils';
import { GraphQLError } from 'graphql';
import { LendingStation } from '../../model/LendingStation';
@ -32,13 +32,8 @@ export class ContactInformationAPI extends DataSource {
this.connection = getConnection();
}
async contactInformation (offset: number, limit: number) {
return await this.connection.getRepository(ContactInformation)
.createQueryBuilder('ci')
.select()
.offset(offset)
.limit(limit)
.getMany();
async contactInformation (offset?: number, limit?: number) {
return await getAllEntity(this.connection, ContactInformation, 'ci', offset, limit);
}
async contactInformationById (id: number) {
@ -91,13 +86,8 @@ export class ContactInformationAPI extends DataSource {
return await deleteEntity(this.connection, Person, 'p', id, userId);
}
async persons (offset: number, limit: number) {
return await this.connection.getRepository(Person)
.createQueryBuilder('person')
.select()
.skip(offset)
.take(limit)
.getMany();
async persons (offset?: number, limit?: number) {
return await getAllEntity(this.connection, Person, 'p', offset, limit);
}
async personById (id: number) {

@ -24,7 +24,7 @@ import { Connection, EntityManager, getConnection } from 'typeorm';
import { CargoBike } from '../../model/CargoBike';
import { LendingStation } from '../../model/LendingStation';
import { TimeFrame } from '../../model/TimeFrame';
import { ActionLogger, deleteEntity, genDateRange, LockUtils } from './utils';
import { ActionLogger, deleteEntity, genDateRange, getAllEntity, LockUtils } from './utils';
export class LendingStationAPI extends DataSource {
connection : Connection
@ -44,14 +44,8 @@ export class LendingStationAPI extends DataSource {
/**
* get all lendingStations
*/
async lendingStations (offset: number, limit: number) {
return await this.connection.getRepository(LendingStation)
.createQueryBuilder('lendingStation')
.select()
.offset(offset)
.limit(limit)
.orderBy('name', 'ASC')
.getMany() || new GraphQLError('Internal Server Error: could not query data from table lendingStation');
async lendingStations (offset?: number, limit?: number) {
return await getAllEntity(this.connection, LendingStation, 'ls', offset, limit);
}
/**
@ -79,13 +73,8 @@ export class LendingStationAPI extends DataSource {
.loadOne();
}
async timeFrames (offset: number, limit: number) {
return await this.connection.getRepository(TimeFrame)
.createQueryBuilder('timeframe')
.select()
.offset(offset)
.limit(limit)
.getMany() || [];
async timeFrames (offset?: number, limit?: number) {
return await getAllEntity(this.connection, TimeFrame, 'tf', offset, limit);
}
async timeFramesByCargoBikeId (id: number) {

@ -23,7 +23,7 @@ import { ContactInformation } from '../../model/ContactInformation';
import { Engagement } from '../../model/Engagement';
import { Participant } from '../../model/Participant';
import { EngagementType } from '../../model/EngagementType';
import { ActionLogger, deleteEntity, genDateRange, LockUtils } from './utils';
import { ActionLogger, deleteEntity, genDateRange, getAllEntity, LockUtils } from './utils';
import { UserInputError } from 'apollo-server-express';
import { GraphQLError } from 'graphql';
@ -42,13 +42,8 @@ export class ParticipantAPI extends DataSource {
.getOne();
}
async getParticipants (offset: number, limit: number) {
return await this.connection.getRepository(Participant)
.createQueryBuilder('participant')
.select()
.offset(offset)
.limit(limit)
.getMany();
async getParticipants (offset?: number, limit?: number) {
return await getAllEntity(this.connection, Participant, 'p', offset, limit);
}
async participantByEngagementId (id: number) {
@ -84,18 +79,25 @@ export class ParticipantAPI extends DataSource {
.getMany();
}
async engagementByCargoBikeId (offset: number, limit: number, id: number) {
async engagementByCargoBikeId (id: number, offset?: number, limit?: number) {
if (limit === null || offset === null) {
return await this.connection.getRepository(Engagement)
.createQueryBuilder('engagement')
.select()
.where('engagement."cargoBikeId" = :id', { id: id })
.orderBy('engagement."dateRange"', 'DESC')
.getMany();
} else {
return await this.connection.getRepository(Engagement)
.createQueryBuilder('engagement')
.select()
.where('engagement."cargoBikeId" = :id', {
id: id
})
.where('engagement."cargoBikeId" = :id', { id: id })
.skip(offset)
.take(limit)
.orderBy('engagement."dateRange"', 'DESC')
.getMany();
}
}
async currentEngagementByCargoBikeId (id: number) {
return await this.connection.getRepository(Engagement)
@ -107,13 +109,8 @@ export class ParticipantAPI extends DataSource {
.getMany();
}
async engagements (offset: number, limit: number) {
return await this.connection.getRepository(Engagement)
.createQueryBuilder('e')
.select()
.skip(offset)
.take(limit)
.getMany();
async engagements (offset?: number, limit?: number) {
return await getAllEntity(this.connection, Engagement, 'e', offset, limit);
}
async engagementById (id: number) {
@ -132,13 +129,8 @@ export class ParticipantAPI extends DataSource {
.getOne();
}
async engagementTypes (offset: number, limit: number) {
return await this.connection.getRepository(EngagementType)
.createQueryBuilder('et')
.select()
.skip(offset)
.take(limit)
.getMany();
async engagementTypes (offset?: number, limit?: number) {
return await getAllEntity(this.connection, Engagement, 'e', offset, limit);
}
async engagementTypeByEngagementId (id: number) {

@ -24,7 +24,7 @@ import { Organisation } from '../../model/Organisation';
import { UserInputError } from 'apollo-server-express';
import { CargoBike } from '../../model/CargoBike';
import { LendingStation } from '../../model/LendingStation';
import { ActionLogger, deleteEntity, LockUtils } from './utils';
import { ActionLogger, deleteEntity, getAllEntity, LockUtils } from './utils';
import { GraphQLError } from 'graphql';
export class ProviderAPI extends DataSource {
@ -42,13 +42,8 @@ export class ProviderAPI extends DataSource {
.getOne();
}
async provider (offset: number, limit: number) {
return await this.connection.getRepository(Provider)
.createQueryBuilder('provider')
.select()
.skip(offset)
.take(limit)
.getMany();
async provider (offset?: number, limit?: number) {
return await getAllEntity(this.connection, Provider, 'p', offset, limit);
}
async providerByOrganisationId (id: number) {
@ -75,13 +70,8 @@ export class ProviderAPI extends DataSource {
.loadOne();
}
async organisations (offset: number, limit: number) {
return await this.connection.getRepository(Organisation)
.createQueryBuilder('o')
.select()
.skip(offset)
.limit(limit)
.getMany();
async organisations (offset?: number, limit?: number) {
return await getAllEntity(this.connection, Organisation, 'o', offset, limit);
}
async organisationById (id: number) {

@ -64,6 +64,22 @@ export async function deleteEntity (connection: Connection, target: ObjectType<L
});
}
export async function getAllEntity (connection: Connection, target: ObjectType<any>, alias: string, offset?: number, limit?: number) {
if (offset === null || limit === null) {
return await connection.getRepository(target)
.createQueryBuilder(alias)
.select()
.getMany();
} else {
return await connection.getRepository(target)
.createQueryBuilder(alias)
.select()
.skip(offset)
.take(limit)
.getMany();
}
}
export class LockUtils {
static async findById (connection: Connection, target: ObjectType<Lockable>, alias: string, id: number): Promise<Lockable> {
return await connection.getRepository(target)

@ -21,7 +21,7 @@ import { DataSource } from 'apollo-datasource';
import { Connection, EntityManager, getConnection } from 'typeorm';
import { WorkshopType } from '../../model/WorkshopType';
import { Workshop } from '../../model/Workshop';
import { ActionLogger, deleteEntity, LockUtils } from './utils';
import { ActionLogger, deleteEntity, getAllEntity, LockUtils } from './utils';
import { UserInputError } from 'apollo-server-express';
import { GraphQLError } from 'graphql';
import { Participant } from '../../model/Participant';
@ -126,13 +126,8 @@ export class WorkshopAPI extends DataSource {
.getOne();
}
async workshopTypes (offset: number, limit: number) {
return await this.connection.getRepository(WorkshopType)
.createQueryBuilder('w')
.select()
.skip(offset)
.take(limit)
.getMany();
async workshopTypes (offset?: number, limit?: number) {
return getAllEntity(this.connection, WorkshopType, 'wt', offset, limit);
}
async workshopById (id: number) {
@ -148,13 +143,8 @@ export class WorkshopAPI extends DataSource {
* @param offset
* @param limit
*/
async workshops (offset: number, limit: number) {
return await this.connection.getRepository(Workshop)
.createQueryBuilder('w')
.select()
.skip(offset)
.take(limit)
.getMany();
async workshops (offset?: number, limit?: number) {
return await getAllEntity(this.connection, Workshop, 'w', offset, limit);
}
async trainer1ByWorkshopId (id: number) {

@ -30,14 +30,14 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
cargoBikes: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
cargoBikes: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadBike)) {
return dataSources.cargoBikeAPI.getCargoBikes(offset, limit);
} else {
return new GraphQLError('Insufficient Permissions');
}
},
bikeEvents: (_:any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
bikeEvents: (_:any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadBikeEvent)) {
return dataSources.cargoBikeAPI.bikeEvents(offset, limit);
} else {
@ -58,14 +58,14 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
bikeEventTypes: (_:any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
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 }) => {
equipment: (_:any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadEquipment)) {
return dataSources.cargoBikeAPI.getEquipment(offset, limit);
} else {
@ -79,7 +79,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
equipmentTypes: (_:any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
equipmentTypes: (_:any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadEquipment)) {
return dataSources.cargoBikeAPI.equipmentTypes(offset, limit);
} else {
@ -102,23 +102,23 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
engagement (parent: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) {
engagement (parent: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) {
if (req.permissions.includes(Permission.ReadEngagement)) {
return dataSources.participantAPI.engagementByCargoBikeId(offset, limit, parent.id);
return dataSources.participantAPI.engagementByCargoBikeId(parent.id, offset, limit);
} else {
return new GraphQLError('Insufficient Permissions');
}
},
participants (parent: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) { // TODO should be done with engagements
participants (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.participantsByCargoBikeId(parent.id);
} else {
return new GraphQLError('Insufficient Permissions');
}
},
equipment (parent: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) {
equipment (parent: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) {
if (req.permissions.includes(Permission.ReadEquipment)) {
return dataSources.cargoBikeAPI.equipmentByCargoBikeId(offset, limit, parent.id);
return dataSources.cargoBikeAPI.equipmentByCargoBikeId(parent.id, offset, limit);
} else {
return new GraphQLError('Insufficient Permissions');
}
@ -130,7 +130,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
bikeEvents (parent: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) {
bikeEvents (parent: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) {
if (req.permissions.includes(Permission.ReadBikeEvent)) {
return dataSources.cargoBikeAPI.bikeEventsByCargoBikeId(parent.id, offset, limit);
} else {
@ -173,6 +173,10 @@ export default {
isLockedByMe: (parent: any, __: any, { req }: { req: any }) => isLockedByMe(parent, { req }),
isLocked: (parent: any, __: any, { req }: { req: any }) => isLocked(parent, { req })
},
EquipmentType: {
isLockedByMe: (parent: any, __: any, { req }: { req: any }) => isLockedByMe(parent, { req }),
isLocked: (parent: any, __: any, { req }: { req: any }) => isLocked(parent, { req })
},
BikeEvent: {
cargoBike (parent: any, __: any, { dataSources, req }: { dataSources: any, req: any }) {
if (req.permissions.includes(Permission.ReadBike)) {

@ -24,7 +24,7 @@ import { isLocked, isLockedByMe } from '../datasources/db/utils';
export default {
Query: {
contactInformation: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
contactInformation: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadPerson)) {
return dataSources.contactInformationAPI.contactInformation(offset, limit);
} else {
@ -45,7 +45,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
persons: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
persons: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadPerson)) {
return dataSources.contactInformationAPI.persons(offset, limit);
} else {

@ -31,7 +31,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
lendingStations: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
lendingStations: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadLendingStation)) {
return dataSources.lendingStationAPI.lendingStations(offset, limit);
} else {
@ -45,7 +45,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
timeframes: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
timeFrames: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadTimeFrame)) {
return dataSources.lendingStationAPI.timeFrames(offset, limit);
} else {

@ -30,7 +30,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
participants: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
participants: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadParticipant)) {
return dataSources.participantAPI.getParticipants(offset, limit);
} else {
@ -44,7 +44,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
engagements: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
engagements: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadEngagement)) {
return dataSources.participantAPI.engagements(offset, limit);
} else {
@ -58,7 +58,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
engagementTypes: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
engagementTypes: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadEngagement)) {
return dataSources.participantAPI.engagementTypes(offset, limit);
} else {

@ -23,7 +23,7 @@ import { isLocked, isLockedByMe } from '../datasources/db/utils';
export default {
Query: {
providers: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
providers: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadProvider)) {
return dataSources.providerAPI.provider(offset, limit);
} else {
@ -37,7 +37,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
organisations: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
organisations: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadOrganisation)) {
return dataSources.providerAPI.organisations(offset, limit);
} else {

@ -31,7 +31,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
workshopTypes: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
workshopTypes: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadWorkshop)) {
return dataSources.workshopAPI.workshopTypes(offset, limit);
} else {
@ -45,7 +45,7 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
workshops: (_: any, { offset, limit }: { offset: number, limit: number }, { dataSources, req }: { dataSources: any, req: any }) => {
workshops: (_: any, { offset, limit }: { offset?: number, limit?: number }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadWorkshop)) {
return dataSources.workshopAPI.workshops(offset, limit);
} else {

@ -21,21 +21,20 @@ import { gql } from 'apollo-server-express';
export default gql`
"timestamp object YYYY-MM-ddThh:mm:ss.sssZ"
scalar Date
"only time hh-mm-ss"
scalar Time
"""
is of american format [-]$[0-9]+.[0-9][0-9]
commas every three digits and . for decimals with 2 digits after the .
There can be a leading -.
There is a currency signe at the first position or second position if - is set.
The kind of currency depends on the database.
"""
scalar Money
"The CargoBike type is central to the graph. You could call it the root."
type CargoBike {
"timestamp object YYYY-MM-ddThh:mm:ss.sssZ"
scalar Date
"only time hh-mm-ss"
scalar Time
"""
is of american format [-]$[0-9]+.[0-9][0-9]
commas every three digits and . for decimals with 2 digits after the .
There can be a leading -.
There is a currency signe at the first position or second position if - is set.
The kind of currency depends on the database.
"""
scalar Money
"The CargoBike type is central to the graph. You could call it the root."
type CargoBike {
id: ID!
"see column A in info tabelle"
group: Group
@ -58,8 +57,10 @@ type CargoBike {
Does not refer to an extra table in the database.
"""
dimensionsAndLoad: DimensionsAndLoad!
"If offset or limit is not provided, both values are ignored"
bikeEvents(offset: Int, limit: Int): [BikeEvent]
equipment(offset: Int!, limit: Int!): [Equipment]
"If offset or limit is not provided, both values are ignored"
equipment(offset: Int, limit: Int): [Equipment]
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
equipmentType: [EquipmentType]
"Sticker State"
@ -72,19 +73,20 @@ type CargoBike {
lendingStation: LendingStation
taxes: Taxes
currentEngagements: [Engagement]
engagement(offset: Int!, limit: Int!): [Engagement]
"If offset or limit is not provided, both values are ignored"
engagement(offset: Int, limit: Int): [Engagement]
timeFrames: [TimeFrame]
isLocked: Boolean!
isLockedByMe: Boolean!
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
"""
if you want to add bike to a lending station, create a new timeFrame with to: Date = null
"""
input CargoBikeCreateInput {
"""
if you want to add bike to a lending station, create a new timeFrame with to: Date = null
"""
input CargoBikeCreateInput {
"see column A in info tabelle"
group: Group!
name: String!
@ -114,12 +116,12 @@ input CargoBikeCreateInput {
providerId: ID
insuranceData: InsuranceDataCreateInput!
taxes: TaxesCreateInput!
}
}
"""
if you want to add bike to a lending station, create a new timeFrame with to: Date = null
"""
input CargoBikeUpdateInput {
"""
if you want to add bike to a lending station, create a new timeFrame with to: Date = null
"""
input CargoBikeUpdateInput {
id: ID!
"see column A in info tabelle"
group: Group
@ -155,9 +157,9 @@ input CargoBikeUpdateInput {
taxes: TaxesUpdateInput
"will keep Bike locked if set to true, default = false"
keepLock: Boolean
}
}
type InsuranceData {
type InsuranceData {
"""
Eventually, this field will become an enum or a separate data table and user can choose from a pool of insurance companies.
"""
@ -181,9 +183,9 @@ type InsuranceData {
"""
projectAllowance: Money
notes: String
}
}
input InsuranceDataCreateInput {
input InsuranceDataCreateInput {
"""
Eventually, this field will become an enum or a separate data table and user can choose from a pool of insurance companies.
"""
@ -207,9 +209,9 @@ input InsuranceDataCreateInput {
"""
projectAllowance: Money
notes: String
}
}
input InsuranceDataUpdateInput {
input InsuranceDataUpdateInput {
"""
Eventually, this field will become an enum or a separate data table and user can choose from a pool of insurance companies.
"""
@ -233,10 +235,10 @@ input InsuranceDataUpdateInput {
"""
projectAllowance: Money
notes: String
}
}
"How are the dimensions and how much weight can handle a bike. This data is merged in the CargoBike table and the BikeModel table."
type DimensionsAndLoad {
"How are the dimensions and how much weight can handle a bike. This data is merged in the CargoBike table and the BikeModel table."
type DimensionsAndLoad {
hasCoverBox: Boolean!
"cover box can be locked"
lockable: Boolean!
@ -250,9 +252,9 @@ type DimensionsAndLoad {
bikeWidth: Float
bikeHeight: Float
bikeWeight: Float
}
}
input DimensionsAndLoadCreateInput {
input DimensionsAndLoadCreateInput {
hasCoverBox: Boolean!
lockable: Boolean!
boxLength: Float!
@ -265,9 +267,9 @@ input DimensionsAndLoadCreateInput {
bikeWidth: Float
bikeHeight: Float
bikeWeight: Float
}
}
input DimensionsAndLoadUpdateInput {
input DimensionsAndLoadUpdateInput {
hasCoverBox: Boolean
lockable: Boolean
boxLength: Float
@ -280,73 +282,73 @@ input DimensionsAndLoadUpdateInput {
bikeWidth: Float
bikeHeight: Float
bikeWeight: Float
}
"""
Some Technical Info about the bike.
This should be 1-1 Relation with the CargoBike.
So no id needed for mutation. One Mutation for the CargoBike will be enough.
"""
type TechnicalEquipment {
}
"""
Some Technical Info about the bike.
This should be 1-1 Relation with the CargoBike.
So no id needed for mutation. One Mutation for the CargoBike will be enough.
"""
type TechnicalEquipment {
bicycleShift: String!
isEBike: Boolean!
hasLightSystem: Boolean!
specialFeatures: String
}
}
input TechnicalEquipmentCreateInput {
input TechnicalEquipmentCreateInput {
bicycleShift: String!
isEBike: Boolean!
hasLightSystem: Boolean!
specialFeatures: String
}
}
input TechnicalEquipmentUpdateInput {
input TechnicalEquipmentUpdateInput {
bicycleShift: String
isEBike: Boolean
hasLightSystem: Boolean
specialFeatures: String
}
"""
The Security Info about the bike.
his should be 1-1 Relation with the CargoBike.
So no id needed for mutation. One Mutation for the CargoBike will be enough.
"""
type Security {
}
"""
The Security Info about the bike.
his should be 1-1 Relation with the CargoBike.
So no id needed for mutation. One Mutation for the CargoBike will be enough.
"""
type Security {
frameNumber: String!
keyNumberFrameLock: String
keyNumberAXAChain: String
policeCoding: String
adfcCoding: String
}
}
input SecurityCreateInput {
input SecurityCreateInput {
frameNumber: String!
keyNumberFrameLock: String
keyNumberAXAChain: String
policeCoding: String
adfcCoding: String
}
}
input SecurityUpdateInput {
input SecurityUpdateInput {
frameNumber: String
keyNumberFrameLock: String
keyNumberAXAChain: String
policeCoding: String
adfcCoding: String
}
}
enum StickerBikeNameState {
enum StickerBikeNameState {
OK
IMPROVE
PRODUCED
NONEED
MISSING
UNKNOWN
}
}
enum Group{
enum Group{
KL
LI
SP
@ -355,9 +357,12 @@ enum Group{
SZ
TS
TK
}
}
type Participant {
"""
A participant in the organization
"""
type Participant {
id: ID!
start: Date!
end: Date
@ -381,9 +386,9 @@ type Participant {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input ParticipantCreateInput {
input ParticipantCreateInput {
"if not set, CURRENT_DATE will be used"
start: Date
end: Date
@ -397,9 +402,9 @@ input ParticipantCreateInput {
"default: false"
memberCoreTeam: Boolean
workshopIds: [ID]
}
}
input ParticipantUpdateInput {
input ParticipantUpdateInput {
id: ID!
"if not set, CURRENT_DATE will be used"
start: Date
@ -415,9 +420,12 @@ input ParticipantUpdateInput {
memberCoreTeam: Boolean
workshopIds: [ID]
keepLock: Boolean
}
}
type Workshop {
"""
A workshop event
"""
type Workshop {
id: ID!
title: String!
description: String!
@ -431,18 +439,18 @@ type Workshop {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input WorkshopCreateInput {
input WorkshopCreateInput {
title: String!
description: String
date: Date!
workshopTypeId: ID!
trainer1Id: ID!
trainer2Id: ID
}
}
input WorkshopUpdateInput {
input WorkshopUpdateInput {
id: ID!
title: String
description: String
@ -451,9 +459,9 @@ input WorkshopUpdateInput {
trainer1Id: ID
trainer2Id: ID
keepLock: Boolean
}
}
type WorkshopType {
type WorkshopType {
id: ID!
name: String!
isLocked: Boolean!
@ -461,18 +469,18 @@ type WorkshopType {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input WorkshopTypeCreateInput {
input WorkshopTypeCreateInput {
name: String!
}
}
input WorkshopTypeUpdateInput {
input WorkshopTypeUpdateInput {
id: ID!
name: String
}
}
type EngagementType {
type EngagementType {
id: ID!
name: String!
description: String!
@ -481,21 +489,21 @@ type EngagementType {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input EngagementTypeCreateInput {
input EngagementTypeCreateInput {
name: String!
description: String
}
}
input EngagementTypeUpdateInput {
input EngagementTypeUpdateInput {
id: ID!
name: String
description: String
keepLock: Boolean
}
}
type Engagement {
type Engagement {
id: ID!
engagementType: EngagementType!
from: Date!
@ -507,9 +515,9 @@ type Engagement {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input EngagementCreateInput {
input EngagementCreateInput {
engagementTypeId: ID!
"will use CURRENT_DATE if not set"
from: Date
@ -517,8 +525,8 @@ input EngagementCreateInput {
to: Date
participantId: ID!
cargoBikeId: ID!
}
input EngagementUpdateInput {
}
input EngagementUpdateInput {
id: ID!
engagementTypeId: ID
from: Date
@ -526,33 +534,33 @@ input EngagementUpdateInput {
participantId: ID
cargoBikeId: ID
keepLock: Boolean
}
}
type Taxes {
type Taxes {
costCenter: String!
organisationArea: OrganisationArea
}
}
input TaxesCreateInput {
input TaxesCreateInput {
costCenter: String!
organisationArea: OrganisationArea
}
}
input TaxesUpdateInput {
input TaxesUpdateInput {
costCenter: String
organisationArea: OrganisationArea
}
}
enum OrganisationArea {
enum OrganisationArea {
IB
ZB
}
}
"""
This type represents a piece of equipment that represents a real physical object.
The object must be unique. So it is possible to tell it apart from similar objects by a serial number.
"""
type Equipment {
"""
This type represents a piece of equipment that represents a real physical object.
The object must be unique. So it is possible to tell it apart from similar objects by a serial number.
"""
type Equipment {
id: ID!
serialNo: String!
title: String!
@ -563,16 +571,16 @@ type Equipment {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input EquipmentCreateInput {
input EquipmentCreateInput {
serialNo: String!
title: String!
description: String
cargoBikeId: ID
}
}
input EquipmentUpdateInput {
input EquipmentUpdateInput {
id: ID!
serialNo: String
title: String
@ -580,9 +588,13 @@ input EquipmentUpdateInput {
cargoBikeId: ID
"will keep Bike locked if set to true, default = false"
keepLock: Boolean
}
}
type EquipmentType {
"""
A type of equipment that is not being tracked but can be assigned
to any bike.
"""
type EquipmentType {
id: ID!
name: String!
description: String!
@ -591,22 +603,22 @@ type EquipmentType {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input EquipmentTypeCreateInput {
input EquipmentTypeCreateInput {
name: String
description: String
}
}
input EquipmentTypeUpdateInput {
input EquipmentTypeUpdateInput {
id: ID!
name: String
description: String
keepLock: Boolean
}
}
"An Event is a point in time, when the state of the bike somehow changed."
type BikeEvent {
"An Event is a point in time, when the state of the bike somehow changed."
type BikeEvent {
id: ID!
bikeEventType: BikeEventType!
cargoBike: CargoBike!
@ -617,16 +629,16 @@ type BikeEvent {
"""
Path to documents
"""
documents: [String]!
documents: [String!]!
remark: String
isLocked: Boolean!
isLockedByMe: Boolean!
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input BikeEventCreateInput {
input BikeEventCreateInput {
bikeEventTypeId: ID!
cargoBikeId: ID!
responsibleId: ID
@ -638,9 +650,9 @@ input BikeEventCreateInput {
"""
documents: [String]
remark: String
}
}
input BikeEventUpdateInput {
input BikeEventUpdateInput {
id: ID!
bikeEventTypeId: ID
cargoBikeId: ID
@ -654,45 +666,47 @@ input BikeEventUpdateInput {
documents: [String]
remark: String
keepLock: Boolean
}
}
type BikeEventType {
type BikeEventType {
id: ID!
name: String!
isLockedByMe: Boolean!
isLocked: Boolean!
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input BikeEventTypeUpdateInput {
input BikeEventTypeUpdateInput {
id: ID!
name: String
keepLock: Boolean
}
}
"(dt. Anbieter) bezieht sich auf die Beziehung einer Person oder Organisation zum Lastenrad"
type Provider {
"(dt. Anbieter) bezieht sich auf die Beziehung einer Person oder Organisation zum Lastenrad"
type Provider {
id: ID!
formName: String
privatePerson: ContactInformation
organisation: Organisation
cargoBikes: [CargoBike]
cargoBikes: [CargoBike!]
isLocked: Boolean!
isLockedByMe: Boolean!
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
"(dt. Anbieter)"
input ProviderCreateInput {
"(dt. Anbieter)"
input ProviderCreateInput {
formName: String!
privatePersonId: ID
organisationId: ID
cargoBikeIds: [ID]
}
cargoBikeIds: [ID!]
}
input ProviderUpdateInput {
input ProviderUpdateInput {
id: ID!
formName: String
privatePersonId: ID
@ -700,37 +714,37 @@ input ProviderUpdateInput {
"cargoBikes are added, you can not take existing relations away. use update cargoBike or add bike to another provider instead"
cargoBikeIds: [ID]
keepLock: Boolean
}
}
"""
A Person can have several instances of contact information.
The reason for this is, that some people have info for interns and externals that are different.
"""
type Person {
"""
A Person can have several instances of contact information.
The reason for this is, that some people have info for interns and externals that are different.
"""
type Person {
id: ID!
name: String!
firstName: String!
contactInformation: [ContactInformation]
contactInformation: [ContactInformation!]
isLocked: Boolean!
isLockedByMe: Boolean!
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input PersonCreateInput {
input PersonCreateInput {
name: String!
firstName: String!
}
}
input PersonUpdateInput {
input PersonUpdateInput {
id: ID!
name: String
firstName: String
keepLock: Boolean
}
}
type ContactInformation {
type ContactInformation {
id: ID!
person: Person!
phone: String
@ -743,18 +757,18 @@ type ContactInformation {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input ContactInformationCreateInput {
input ContactInformationCreateInput {
personId: ID!
phone: String
phone2: String
email: String
email2: String
note: String
}
}
input ContactInformationUpdateInput {
input ContactInformationUpdateInput {
id: ID!
personId: ID
phone: String
@ -763,14 +777,14 @@ input ContactInformationUpdateInput {
email2: String
note: String
keepLock: Boolean
}
}
type Organisation {
type Organisation {
id: ID!
name: String!
address: Address
"(dt. Ausleihstation)"
lendingStations: [LendingStation]
lendingStations: [LendingStation!]
"registration number of association"
associationNo: String
"If Club, at what court registered"
@ -783,9 +797,9 @@ type Organisation {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input OrganisationCreateInput {
input OrganisationCreateInput {
address: AddressCreateInput!
name: String!
"registration number of association"
@ -794,9 +808,9 @@ input OrganisationCreateInput {
registeredAt: String
contactInformationId: ID
otherData: String
}
}
input OrganisationUpdateInput {
input OrganisationUpdateInput {
id: ID!
address: AddressCreateInput
name: String
@ -807,18 +821,18 @@ input OrganisationUpdateInput {
contactInformationId: ID
otherData: String
keepLock: Boolean
}
}
"(dt. Standort)"
type LendingStation {
"(dt. Standort)"
type LendingStation {
id: ID!
name: String!
contactInformationIntern: ContactInformation
contactInformationExtern: ContactInformation
address: Address!
timeFrames: [TimeFrame]!
timeFrames: [TimeFrame!]!
loanPeriod: LoanPeriod
cargoBikes: [CargoBike]
cargoBikes: [CargoBike!]
"Total amount of cargoBikes currently assigned to the lending station"
numCargoBikes: Int!
organisation: Organisation
@ -827,24 +841,24 @@ type LendingStation {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
"""
If you want to create LendingStation with cargoBikes, use createTimeFrame and set to: Date = null
"""
input LendingStationCreateInput {
"""
If you want to create LendingStation with cargoBikes, use createTimeFrame and set to: Date = null
"""
input LendingStationCreateInput {
name: String!
contactInformationInternId: ID
contactInformationExternId: ID
address: AddressCreateInput!
loanPeriod: LoanPeriodInput
organisationId: ID
}
}
"""
If you want to create LendingStation with cargoBikes, use createTimeFrame and set to: Date = null
"""
input LendingStationUpdateInput {
"""
If you want to create LendingStation with cargoBikes, use createTimeFrame and set to: Date = null
"""
input LendingStationUpdateInput {
id: ID!
name: String
contactInformationInternId: ID
@ -853,12 +867,12 @@ input LendingStationUpdateInput {
loanPeriod: LoanPeriodInput
organisationId: ID
keepLock: Boolean
}
}
"""
(dt. Ausleihzeiten) not implemented
"""
type LoanPeriod {
"""
(dt. Ausleihzeiten) not implemented
"""
type LoanPeriod {
generalRemark: String
"notes for each day of the week, starting on Monday"
notes: [String]
@ -867,24 +881,24 @@ type LoanPeriod {
Starting with Monday from, Monday to, Tuesday from, ..., Sunday to
"""
loanTimes: [String]
}
}
"""
(dt. Ausleihzeiten)
"""
input LoanPeriodInput {
"""
(dt. Ausleihzeiten)
"""
input LoanPeriodInput {
generalRemark: String
"notes for each day of the week, starting on Monday"
notes: [String]
notes: [String!]
"""
Loan times from and until for each day of the week.
Starting with Monday from, Monday to, Tuesday from, ..., Sunday to
"""
loanTimes: [String]
}
loanTimes: [String!]
}
"(dt. Zeitscheibe) When was a bike where"
type TimeFrame {
"(dt. Zeitscheibe) When was a bike where"
type TimeFrame {
id: ID!
"format YYYY-MM-dd"
from: Date!
@ -898,17 +912,17 @@ type TimeFrame {
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
}
input TimeFrameCreateInput {
input TimeFrameCreateInput {
from: Date!
to: Date
note: String
lendingStationId: ID!
cargoBikeId: ID!
}
}
input TimeFrameUpdateInput {
input TimeFrameUpdateInput {
id: ID!
from: Date
to: Date
@ -916,27 +930,27 @@ input TimeFrameUpdateInput {
lendingStationId: ID
cargoBikeId: ID
keepLock: Boolean
}
}
type Address {
type Address {
street: String!
number: String!
zip: String!
}
}
input AddressCreateInput {
input AddressCreateInput {
street: String!
number: String!
zip: String!
}
}
input AddressUpdateInput {
input AddressUpdateInput {
street: String
number: String
zip: String
}
}
type ActionLog {
type ActionLog {
id: ID!
userId: ID!
date: Date!
@ -946,56 +960,70 @@ type ActionLog {
entriesOld: String!
"in json format"
entriesNew: String!
}
}
type Query {
type Query {
"Will (eventually) return all properties of cargo bike"
cargoBikeById(id:ID!): CargoBike
"returns cargoBikes ordered by name ascending, relations are not loaded, use cargoBikeById instead"
cargoBikes(offset: Int!, limit: Int!): [CargoBike]!
"Returns cargoBikes ordered by name ascending. If offset or limit is not provided, both values are ignored."
cargoBikes(offset: Int, limit: Int): [CargoBike!]!
engagementById(id: ID!): Engagement
engagements(offset: Int!, limit: Int!): [Engagement]!
"If offset or limit is not provided, both values are ignored"
engagements(offset: Int, limit: Int): [Engagement!]!
engagementTypeById(id: ID!): EngagementType
engagementTypes(offset: Int!, limit: Int!): [EngagementType]!
"If offset or limit is not provided, both values are ignored"
engagementTypes(offset: Int, limit: Int): [EngagementType!]!
"equipment by id, will return null if id not found"
equipmentById(id: ID!): Equipment
equipment(offset: Int!, limit: Int!): [Equipment]!
"If offset or limit is not provided, both values are ignored"
equipment(offset: Int, limit: Int): [Equipment!]!
equipmentTypeById(id: ID!): EquipmentType
equipmentTypes(offset: Int!, limit: Int!): [EquipmentType]!
"If offset or limit is not provided, both values are ignored"
equipmentTypes(offset: Int, limit: Int): [EquipmentType!]!
"return null if id not found"
providerById(id:ID!): Provider
"unique equipment with pagination, contains relation to bike (with no further joins), so if you wanna know more about the bike, use cargoBikeById"
providers(offset: Int!, limit: Int!): [Provider]!
"Returns providers with pagination. If offset or limit is not provided, both values are ignored"
providers(offset: Int, limit: Int): [Provider!]!
"participant by id"
participantById(id:ID!): Participant
participants(offset: Int!, limit: Int!): [ Participant]!
"If offset or limit is not provided, both values are ignored"
participants(offset: Int, limit: Int): [Participant!]!
workshopTypeById(id: ID!): WorkshopType
workshopTypes(offset: Int!, limit: Int!): [WorkshopType]!
"If offset or limit is not provided, both values are ignored"
workshopTypes(offset: Int, limit: Int): [WorkshopType!]!
workshopById(id: ID!): Workshop
workshops(offset: Int!, limit: Int!): [Workshop]!
"If offset or limit is not provided, both values are ignored"
workshops(offset: Int, limit: Int): [Workshop!]!
lendingStationById(id:ID!): LendingStation
lendingStations(offset: Int!, limit: Int!): [LendingStation]!
"If offset or limit is not provided, both values are ignored"
lendingStations(offset: Int, limit: Int): [LendingStation!]!
organisationById(id: ID!): Organisation
organisations(offset: Int!, limit: Int!): [Organisation]!
"If offset or limit is not provided, both values are ignored"
organisations(offset: Int, limit: Int): [Organisation!]!
timeFrameById(id: ID!): TimeFrame
timeframes(offset: Int!, limit: Int!): [TimeFrame]!
"If offset or limit is not provided, both values are ignored"
timeFrames(offset: Int, limit: Int): [TimeFrame!]!
contactInformationById(id: ID!): ContactInformation
contactInformation(offset: Int!, limit: Int!): [ContactInformation]!
"If offset or limit is not provided, both values are ignored"
contactInformation(offset: Int, limit: Int): [ContactInformation!]!
personById(id: ID!): Person
persons(offset: Int!, limit: Int!): [Person]
bikeEventTypes(offset: Int!, limit: Int!): [BikeEventType]
"If offset or limit is not provided, both values are ignored"
persons(offset: Int, limit: Int): [Person!]
"If offset or limit is not provided, both values are ignored"
bikeEventTypes(offset: Int, limit: Int): [BikeEventType!]
bikeEventTypeByd(id: ID!): BikeEventType
bikeEvents(offset: Int!, limit: Int!): [BikeEvent]!
"If offset or limit is not provided, both values are ignored"
bikeEvents(offset: Int, limit: Int): [BikeEvent!]!
bikeEventById(id:ID!): BikeEvent
"actionLog for current user"
actionLog: [ActionLog]
actionLog: [ActionLog!]
"actionLog for specific user"
actionLogByUser(id: ID!): [ActionLog]
actionLogByUser(id: ID!): [ActionLog!]
"actionLog form all users"
actionLogAll: [ActionLog]
}
actionLogAll: [ActionLog!]
}
type Mutation {
type Mutation {
"""
CARGO BIKE
creates new cargoBike and returns cargobike with new ID
@ -1105,6 +1133,6 @@ type Mutation {
unlockOrganisation(id: ID!): Boolean!
updateOrganisation(organisation: OrganisationUpdateInput!): Organisation!
deleteOrganisation(id: ID!): Boolean!
}
}
`;

Loading…
Cancel
Save