src/schema/*: modified mutation and mutation responses

pull/8/head
leonnicolas 4 years ago
parent 0bc8934560
commit b923aa4c88
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -1,6 +1,7 @@
import { DataSource } from 'apollo-datasource';
import { getConnection, Connection } from 'typeorm';
import { CargoBike } from '../../model/CargoBike';
import { GraphQLError } from 'graphql';
/**
* extended datasource to feed resolvers with data about cargoBikes
*/
@ -53,32 +54,18 @@ export class CargoBikeAPI extends DataSource {
.set({ name: bike.name })
.where('id = :id', { id: bike.id })
.execute();
return {
success: true
};
return bike;
} else {
return {
success: false,
message: 'no bike with given id ' + cargoBike.id + ' found.'
};
return new GraphQLError('ID not in database');
}
} else {
// create new bike
await this.connection.manager.createQueryBuilder()
.insert()
.into(CargoBike)
.values([{
modelName: cargoBike.modelName,
numberOfWheels: cargoBike.numberOfWheels,
forCargo: cargoBike.forCargo,
forChildren: cargoBike.forChildren
}
])
.values([cargoBike])
.execute();
return {
success: true,
message: 'new entry'
};
return cargoBike;
}
}
}

@ -1,27 +1,6 @@
import { Column } from 'typeorm';
export abstract class Bike {
@Column({
nullable: true
})
description: string;
@Column()
modelName: string;
@Column()
numberOfWheels: number;
@Column()
forCargo: boolean;
@Column()
forChildren: boolean;
@Column()
numberOfChildren: number;
// technical Information
export class TechnicalEquipment {
@Column()
bicycleShift: string;
@ -31,49 +10,100 @@ export abstract class Bike {
@Column()
hasLightSystem: boolean;
@Column()
@Column({
nullable: true
})
specialFeatures: string;
}
// dimensions and load
export class DimensionsAndLoad {
@Column()
hasCoverBox: boolean;
@Column()
lockable:boolean;
@Column()
@Column({
type: 'decimal'
})
boxLength: number;
@Column()
@Column({
type: 'decimal'
})
boxWidth: number;
@Column()
@Column({
type: 'decimal'
})
boxHeight: number;
@Column()
@Column({
type: 'decimal'
})
maxWeightBox: number;
@Column()
@Column({
type: 'decimal'
})
maxWeightLuggageRack: number;
@Column()
@Column({
type: 'decimal'
})
maxWeightTotal: number;
@Column()
@Column({
type: 'decimal'
})
bikeLength: number;
@Column({
nullable: true
nullable: true,
type: 'decimal'
})
bikeWidth: number;
@Column({
nullable: true
nullable: true,
type: 'decimal'
})
bikeHeight: number;
@Column({
nullable: true
nullable: true,
type: 'decimal'
})
bikeWeight: number;
}
export abstract class Bike {
@Column({
nullable: true
})
description: string;
@Column()
modelName: string;
@Column()
numberOfWheels: number;
@Column()
forCargo: boolean;
@Column()
forChildren: boolean;
@Column()
numberOfChildren: number;
@Column(type => TechnicalEquipment)
technicalEquipment: TechnicalEquipment;
@Column(type => DimensionsAndLoad)
dimensionsAndLoad: DimensionsAndLoad;
}

@ -30,6 +30,31 @@ export enum StickerBikeNameState {
UNKNOWN
}
export class Security {
@Column()
frameNumber: string;
@Column({
nullable: true
})
keyNoFrameLock: string;
@Column({
nullable: true
})
keyNoAXAChain: string;
@Column({
nullable: true
})
policeCodeing: string;
@Column({
nullable: true
})
adfsCoding: string;
}
@Entity()
export class CargoBike extends Bike {
@PrimaryGeneratedColumn()
@ -61,36 +86,19 @@ export class CargoBike extends Bike {
chainSwaps: ChainSwap[]
// Security information
@Column()
frameNumber: string;
@Column({
nullable: true
})
keyNoFrameLock: string;
@Column({
nullable: true
})
keyNoAXAChain: string;
@Column(type => Security)
security: Security;
@Column({
type: 'enum',
enum: StickerBikeNameState,
nullable: true
})
policeCodeing: string;
stickerBikeNameState: StickerBikeNameState;
@Column({
nullable: true
})
adfsCoding: string;
@Column({
type: 'enum',
enum: StickerBikeNameState
})
stickerBikeNameState: StickerBikeNameState;
@Column()
note: string;
@ManyToOne(type => Provider, {

@ -5,21 +5,21 @@ export class InsuranceData {
name: string;
@Column()
benefector: string;
benefactor: string;
@Column()
noPnP: string;
@Column()
maintananceResponisble: string;
maintananceResponsible: string;
@Column()
maintanceBenfector: string;
maintananceBenefactor: string;
@Column({
nullable: true
})
maintanceAgreement: string;
maintananceAgreement: string;
@Column({
nullable: true

@ -14,12 +14,12 @@ type CargoBike {
numberOfWheels: Int
forCargo: Boolean
forChildren: Boolean
numberOfChildren: Int
numberOfChildren: Int!
"""
Safety is a custom type, that stores information about security features.
TODO: Should this be calles Security?
"""
security: Security
security: Security!
"""
Does not refere to an extra table in the database.
"""
@ -56,7 +56,26 @@ type InsuranceData {
noPnP: String!
"eg. Anbieter, flotte, eigenleistung"
maintananceResponsible: String!
maintanceBenefector: String!
maintananceBenefactor: String!
maintananceAgreement: String
hasFixedRate: Boolean!
fixedRate: Float
"Projektzuschuss"
projectAllowance: Float
notes: String
}
input InsuranceDataInput {
"""
Eventuelly, this field will become an enum or a seperate data table and user can choose from a pool of insurance companies.
"""
name: String!
benefactor: String!
billing: String!
noPnP: String!
"eg. Anbieter, flotte, eigenleistung"
maintananceResponsible: String!
maintananceBenefactor: String!
maintananceAgreement: String
hasFixedRate: Boolean!
fixedRate: Float
@ -121,7 +140,12 @@ type Participant {
}
type Taxes {
costCenter: String
costCenter: String!
organizationArea: OrganizationArea
}
input TaxesInput {
costCenter: String!
organizationArea: OrganizationArea
}
@ -184,7 +208,7 @@ enum BikeEventType {
type DimensionsAndLoad {
hasCoverBox: Boolean!
lockable: Boolean!
boxLenght: Float!
boxLength: Float!
boxWidth: Float!
boxHeight: Float!
maxWeightBox: Float!
@ -199,7 +223,7 @@ type DimensionsAndLoad {
input DimensionsAndLoadInput {
hasCoverBox: Boolean!
lockable: Boolean!
boxLenght: Float!
boxLength: Float!
boxWidth: Float!
boxHeight: Float!
maxWeightBox: Float!
@ -217,16 +241,16 @@ 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
hasLightingSystem: Boolean
bicycleShift: String!
isEBike: Boolean!
hasLightSystem: Boolean!
specialFeatures: String
}
input TechnicalEquipmentInput {
bicycleShift: String
isEBike: Boolean
hasLightingSystem: Boolean
bicycleShift: String!
isEBike: Boolean!
hasLightSystem: Boolean!
specialFeatures: String
}
@ -351,12 +375,6 @@ type Query {
contactInformation: [ContactInformation]!
}
type UpdateBikeResponse {
success: Boolean!
message: String
cargoBike: CargoBike
}
input CargoBikeInput {
"if null, then new bike will be created, else old bike will be updated."
id: ID
@ -372,22 +390,25 @@ input CargoBikeInput {
Safety is a custom type, that stores information about security features.
TODO: Should this be calles Security?
"""
security: SecurityInput
security: SecurityInput!
"""
Does not refere to an extra table in the database.
"""
technicalEquipment: TechnicalEquipmentInput
technicalEquipment: TechnicalEquipmentInput!
"""
Does not refere to an extra table in the database.
"""
dimensionsAndLoad: DimensionsAndLoadInput
dimensionsAndLoad: DimensionsAndLoadInput!
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String]
"Sticker State"
stickerBikeNameState: StickerBikeNameState
note: String
provider: String
insuranceData: String
insuranceData: InsuranceDataInput!
taxes: TaxesInput
}
input SecurityInput {
@ -400,9 +421,9 @@ input SecurityInput {
type Mutation {
"for testing"
addBike(id: ID!, name: String): UpdateBikeResponse!
addBike(id: ID!, name: String): CargoBike!
"if id: null, then new bike will be created, else old bike will be updated"
cargoBike(cargoBike: CargoBikeInput!): UpdateBikeResponse!
cargoBike(cargoBike: CargoBikeInput!): CargoBike!
}
`;

Loading…
Cancel
Save