Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as shortid from 'shortid';
import { Field, ID, Int, InterfaceType, ObjectType } from 'type-graphql';
import {
BeforeInsert,
Column,
CreateDateColumn,
PrimaryColumn,
PrimaryGeneratedColumn,
UpdateDateColumn,
VersionColumn
} from 'typeorm';
import { IDType } from './types';
// This interface adds all of the base type-graphql fields to our BaseClass
@InterfaceType()
export abstract class BaseGraphQLObject {
@Field(() => ID)
id!: IDType;
@Field() createdAt!: Date;
@Field() createdById?: IDType;
@Field({ nullable: true })
updatedAt?: Date;
@Field({ nullable: true })
updatedById?: IDType;
@Field({ nullable: true })
deletedAt?: Date;
@Field({ nullable: true })
deletedById?: IDType;
import { Field, InterfaceType } from "type-graphql";
import { Vector } from "../../starship/Vector";
@InterfaceType()
export abstract class Locatable {
@Field(type => Vector)
position!: Vector;
}
import { Field, ID, InterfaceType, ObjectType } from 'type-graphql';
import { IDType } from '../core';
@InterfaceType()
export abstract class DeleteResponse {
@Field(type => ID)
id!: IDType;
}
@ObjectType()
export class StandardDeleteResponse {
@Field(type => ID)
id!: IDType;
}
import { HttpException, HttpStatus } from '@nestjs/common';
import { ApiModelProperty } from '@nestjs/swagger';
import { IsOptional, IsUUID, validate, ValidationError } from 'class-validator';
import { Field, ID, InputType, InterfaceType, ObjectType } from 'type-graphql';
import { IBaseDto } from './interfaces/base.interface';
@InterfaceType({ isAbstract: true })
@ObjectType({ isAbstract: true })
@InputType({ isAbstract: true })
export abstract class BaseDto implements IBaseDto {
@IsOptional()
@IsUUID()
@ApiModelProperty()
@Field(() => ID)
id: string;
async validate(): Promise {
const errors: ValidationError[] = await validate(Object.assign({}, this), {
whitelist: true,
skipMissingProperties: true,
});
if (errors.length > 0) {
import { Field, InterfaceType } from "type-graphql";
import { Vector } from "../../starship/Vector";
@InterfaceType()
export abstract class Body {
@Field()
name!: string;
@Field()
type!: string;
@Field()
mass!: number;
@Field()
diameter!: number;
@Field()
gravity!: number;
import { Field, ID, InterfaceType } from 'type-graphql';
@InterfaceType()
export abstract class Node {
@Field(type => ID, { name: 'id' })
relayId: string;
}