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

@ -1,27 +1,6 @@
import { Column } from 'typeorm'; import { Column } from 'typeorm';
export abstract class Bike { export class TechnicalEquipment {
@Column({
nullable: true
})
description: string;
@Column()
modelName: string;
@Column()
numberOfWheels: number;
@Column()
forCargo: boolean;
@Column()
forChildren: boolean;
@Column()
numberOfChildren: number;
// technical Information
@Column() @Column()
bicycleShift: string; bicycleShift: string;
@ -31,49 +10,100 @@ export abstract class Bike {
@Column() @Column()
hasLightSystem: boolean; hasLightSystem: boolean;
@Column() @Column({
nullable: true
})
specialFeatures: string; specialFeatures: string;
}
// dimensions and load export class DimensionsAndLoad {
@Column() @Column()
hasCoverBox: boolean; hasCoverBox: boolean;
@Column() @Column()
lockable:boolean; lockable:boolean;
@Column() @Column({
type: 'decimal'
})
boxLength: number; boxLength: number;
@Column() @Column({
type: 'decimal'
})
boxWidth: number; boxWidth: number;
@Column() @Column({
type: 'decimal'
})
boxHeight: number; boxHeight: number;
@Column() @Column({
type: 'decimal'
})
maxWeightBox: number; maxWeightBox: number;
@Column() @Column({
type: 'decimal'
})
maxWeightLuggageRack: number; maxWeightLuggageRack: number;
@Column() @Column({
type: 'decimal'
})
maxWeightTotal: number; maxWeightTotal: number;
@Column() @Column({
type: 'decimal'
})
bikeLength: number; bikeLength: number;
@Column({ @Column({
nullable: true nullable: true,
type: 'decimal'
}) })
bikeWidth: number; bikeWidth: number;
@Column({ @Column({
nullable: true nullable: true,
type: 'decimal'
}) })
bikeHeight: number; bikeHeight: number;
@Column({ @Column({
nullable: true nullable: true,
type: 'decimal'
}) })
bikeWeight: number; 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 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() @Entity()
export class CargoBike extends Bike { export class CargoBike extends Bike {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
@ -61,36 +86,19 @@ export class CargoBike extends Bike {
chainSwaps: ChainSwap[] chainSwaps: ChainSwap[]
// Security information // Security information
@Column() @Column(type => Security)
frameNumber: string; security: Security;
@Column({
nullable: true
})
keyNoFrameLock: string;
@Column({
nullable: true
})
keyNoAXAChain: string;
@Column({ @Column({
type: 'enum',
enum: StickerBikeNameState,
nullable: true nullable: true
}) })
policeCodeing: string; stickerBikeNameState: StickerBikeNameState;
@Column({ @Column({
nullable: true nullable: true
}) })
adfsCoding: string;
@Column({
type: 'enum',
enum: StickerBikeNameState
})
stickerBikeNameState: StickerBikeNameState;
@Column()
note: string; note: string;
@ManyToOne(type => Provider, { @ManyToOne(type => Provider, {

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

@ -14,12 +14,12 @@ type CargoBike {
numberOfWheels: Int numberOfWheels: Int
forCargo: Boolean forCargo: Boolean
forChildren: Boolean forChildren: Boolean
numberOfChildren: Int numberOfChildren: Int!
""" """
Safety is a custom type, that stores information about security features. Safety is a custom type, that stores information about security features.
TODO: Should this be calles Security? TODO: Should this be calles Security?
""" """
security: Security security: Security!
""" """
Does not refere to an extra table in the database. Does not refere to an extra table in the database.
""" """
@ -56,7 +56,26 @@ type InsuranceData {
noPnP: String! noPnP: String!
"eg. Anbieter, flotte, eigenleistung" "eg. Anbieter, flotte, eigenleistung"
maintananceResponsible: String! 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 maintananceAgreement: String
hasFixedRate: Boolean! hasFixedRate: Boolean!
fixedRate: Float fixedRate: Float
@ -121,7 +140,12 @@ type Participant {
} }
type Taxes { type Taxes {
costCenter: String costCenter: String!
organizationArea: OrganizationArea
}
input TaxesInput {
costCenter: String!
organizationArea: OrganizationArea organizationArea: OrganizationArea
} }
@ -184,7 +208,7 @@ enum BikeEventType {
type DimensionsAndLoad { type DimensionsAndLoad {
hasCoverBox: Boolean! hasCoverBox: Boolean!
lockable: Boolean! lockable: Boolean!
boxLenght: Float! boxLength: Float!
boxWidth: Float! boxWidth: Float!
boxHeight: Float! boxHeight: Float!
maxWeightBox: Float! maxWeightBox: Float!
@ -199,7 +223,7 @@ type DimensionsAndLoad {
input DimensionsAndLoadInput { input DimensionsAndLoadInput {
hasCoverBox: Boolean! hasCoverBox: Boolean!
lockable: Boolean! lockable: Boolean!
boxLenght: Float! boxLength: Float!
boxWidth: Float! boxWidth: Float!
boxHeight: Float! boxHeight: Float!
maxWeightBox: 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. So no id needed for mutation. One Mutation for the CargoBike will be enough.
""" """
type TechnicalEquipment { type TechnicalEquipment {
bicycleShift: String bicycleShift: String!
isEBike: Boolean isEBike: Boolean!
hasLightingSystem: Boolean hasLightSystem: Boolean!
specialFeatures: String specialFeatures: String
} }
input TechnicalEquipmentInput { input TechnicalEquipmentInput {
bicycleShift: String bicycleShift: String!
isEBike: Boolean isEBike: Boolean!
hasLightingSystem: Boolean hasLightSystem: Boolean!
specialFeatures: String specialFeatures: String
} }
@ -351,12 +375,6 @@ type Query {
contactInformation: [ContactInformation]! contactInformation: [ContactInformation]!
} }
type UpdateBikeResponse {
success: Boolean!
message: String
cargoBike: CargoBike
}
input CargoBikeInput { input CargoBikeInput {
"if null, then new bike will be created, else old bike will be updated." "if null, then new bike will be created, else old bike will be updated."
id: ID id: ID
@ -372,22 +390,25 @@ input CargoBikeInput {
Safety is a custom type, that stores information about security features. Safety is a custom type, that stores information about security features.
TODO: Should this be calles Security? TODO: Should this be calles Security?
""" """
security: SecurityInput security: SecurityInput!
""" """
Does not refere to an extra table in the database. Does not refere to an extra table in the database.
""" """
technicalEquipment: TechnicalEquipmentInput technicalEquipment: TechnicalEquipmentInput!
""" """
Does not refere to an extra table in the database. 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" "Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String] otherEquipment: [String]
"Sticker State" "Sticker State"
stickerBikeNameState: StickerBikeNameState stickerBikeNameState: StickerBikeNameState
note: String note: String
provider: String provider: String
insuranceData: String insuranceData: InsuranceDataInput!
taxes: TaxesInput
} }
input SecurityInput { input SecurityInput {
@ -400,9 +421,9 @@ input SecurityInput {
type Mutation { type Mutation {
"for testing" "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" "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