How to use the type-graphql.InterfaceType function in type-graphql

To help you get started, weโ€™ve selected a few type-graphql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github goldcaddy77 / warthog / src / core / BaseModel.ts View on Github external
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;
github jorisvddonk / WelcomeToTheFuture / backend / universe / interfaces / Locatable.ts View on Github external
import { Field, InterfaceType } from "type-graphql";
import { Vector } from "../../starship/Vector";

@InterfaceType()
export abstract class Locatable {
  @Field(type => Vector)
  position!: Vector;
}
github goldcaddy77 / warthog / src / tgql / DeleteResponse.ts View on Github external
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;
}
github magishift / magishift.core / src / base / base.dto.ts View on Github external
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) {
github jorisvddonk / WelcomeToTheFuture / backend / universe / interfaces / Body.ts View on Github external
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;
github kazekyo / nestjs-graphql-relay / src / nodes / models / node.model.ts View on Github external
import { Field, ID, InterfaceType } from 'type-graphql';

@InterfaceType()
export abstract class Node {
  @Field(type => ID, { name: 'id' })
  relayId: string;
}