How to use the type-graphql.ObjectType 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 wemaintain / auto-relay / tests / suites / _typeorm / entities / recipe.ts View on Github external
import { Entity, PrimaryGeneratedColumn, Column, OneToMany, ManyToOne } from 'typeorm'
import { ObjectType, Field, ID } from 'type-graphql';
import { Rate } from './rate';
import { User } from './user';
import { RelayedConnection } from 'auto-relay';

@Entity()
@ObjectType()
export class Recipe {
  @Field(type => ID)
  @PrimaryGeneratedColumn()
  readonly id!: number;

  @Field()
  @Column()
  title!: string;

  @Field({ nullable: true })
  @Column({ nullable: true })
  description?: string;

  
  @OneToMany(type => Rate, rate => rate.recipe)
  @RelayedConnection(() => Rate)
github SolidZORO / leaa / packages / _leaa-common / src / entrys / attachment.entity.ts View on Github external
import { Index, Entity, Column } from 'typeorm';
import { ObjectType, Field, Int } from 'type-graphql';

import { Base } from '@leaa/common/src/entrys';

@Entity('attachments')
@Index('attachments_uuid_unique', ['uuid'], { unique: true })
@ObjectType()
export class Attachment extends Base {
  @Column({ type: 'varchar', length: 48, unique: true })
  @Field(() => String)
  uuid!: string;

  @Column({ type: 'varchar', length: 255 })
  @Field(() => String)
  title!: string;

  @Column({ type: 'varchar', length: 255 })
  @Field(() => String)
  alt!: string;

  @Column({ type: 'varchar', length: 16 })
  @Field(() => String)
  type!: string;
github mabuonomo / yggdrasil-ts / src / models / socialModel.ts View on Github external
import "reflect-metadata";
import { ObjectType as ObjectTypeQL, Field as FieldQL } from "type-graphql";
import { Column as ColumnORM } from "typeorm";
import { SocialInterface } from "../interfaces/models/socialInterface";

@ObjectTypeQL()
export class SocialModel implements SocialInterface {

    @FieldQL()
    @ColumnORM()
    id_facebook: String;

    @FieldQL()
    @ColumnORM()
    id_google: String;
}
github SolidZORO / leaa / packages / _leaa-common / src / entrys / role.entity.ts View on Github external
import { Index, Entity, Column, JoinTable, ManyToMany } from 'typeorm';
import { ObjectType, Field } from 'type-graphql';

import { Base, User, Permission } from '@leaa/common/src/entrys';

@Entity('roles')
@Index('roles_name_unique', ['name'], { unique: true })
@Index('roles_slug_unique', ['slug'], { unique: true })
@ObjectType()
export class Role extends Base {
  @Column({ type: 'varchar', length: 32, unique: true })
  @Field(() => String)
  name!: string;

  @Column({ type: 'varchar', length: 32, unique: true })
  @Field(() => String)
  slug!: string;

  @ManyToMany(
    () => Permission,
    permission => permission.roles,
  )
  @JoinTable()
  @Field(() => [Permission], { nullable: true })
  permissions?: Permission[];
github iotexproject / iotex-explorer / src / api-gateway / resolvers / antenna-types.ts View on Github external
export class PlumFinalizeExit {
  @Field(_ => String)
  public subChainAddress: string;
  @Field(_ => Int)
  public coinID: number;
}

@InputType("PlumSettleDepositInput")
@ObjectType()
export class PlumSettleDeposit {
  @Field(_ => Int)
  public coinID: number;
}

@InputType("PlumTransferInput")
@ObjectType()
export class PlumTransfer {
  @Field(_ => Int)
  public coinID: number;
  @Field(_ => BufferScalar)
  public denomination: Buffer;
  @Field(_ => String)
  public owner: string;
  @Field(_ => String)
  public recipient: string;
}

@InputType("SetRewardInput")
@ObjectType()
export class SetReward {
  @Field(_ => BufferScalar)
  public amount: string;
github jorisvddonk / WelcomeToTheFuture / backend / lib / Page / PageInfo.ts View on Github external
import { ObjectType, Field } from "type-graphql";
@ObjectType()
export class PageInfo {
  @Field({ nullable: true })
  startCursor: string;
  @Field({ nullable: true })
  endCursor: string;
  @Field()
  hasMore: boolean;
  @Field()
  count: number;
}
github benawad / type-graphql-series / src / entity / User.ts View on Github external
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from "typeorm";
import { ObjectType, Field, ID, Root } from "type-graphql";

@ObjectType()
@Entity()
export class User extends BaseEntity {
  @Field(() => ID)
  @PrimaryGeneratedColumn()
  id: number;

  @Field()
  @Column()
  firstName: string;

  @Field()
  @Column()
  lastName: string;

  @Field()
  @Column("text", { unique: true })
github magishift / magishift.core / src / common / backOfficeUser / backOfficeUser.dto.ts View on Github external
import { Transform } from 'class-transformer';
import { IsString } from 'class-validator';
import { Field, InputType, ObjectType } from 'type-graphql';
import { Form, FormField } from '../../crud/form.decorator';
import { Grid, GridColumn } from '../../crud/grid.decorator';
import { FieldTypes } from '../../crud/interfaces/form.interface';
import { IUserDto } from '../../user/interfaces/user.interface';
import { UserDto } from '../../user/user.dto';
import { IUserRoleDto } from '../../user/userRole/interfaces/userRole.interface';
import { BackOfficeRoleDto } from './backOfficeRole/backOfficeRole.dto';
import { BO_ROLE_ENDPOINT } from './backOfficeRole/interfaces/backOfficeUser.const';
import { BO_USER_ENDPOINT } from './interfaces/backOfficeUser.const';

@Grid()
@Form()
@ObjectType(BO_USER_ENDPOINT)
@InputType()
export class BackOfficeUserDto extends UserDto implements IUserDto {
  @IsString()
  @Field(() => [BackOfficeRoleDto], { nullable: true })
  @ApiModelProperty()
  @FormField({
    label: 'Roles',
    type: FieldTypes.Autocomplete,
    dataSource: { url: BO_ROLE_ENDPOINT, searchParams: ['name'] },
    multiple: true,
    group: 'Credentials',
  })
  @GridColumn({ text: 'Role' })
  @Transform(role => role.string)
  realmRoles: IUserRoleDto[];
}
github jimmyleray / Emendare / server / src / resolvers / text / text.resolver.ts View on Github external
import { Text } from '../../entities'
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'
import { TextService, AuthService } from '../../services'
import { PostTextInputs } from './inputs'
import {
  Response,
  IdInput,
  withAuthentication,
  pubSubEvent
} from '../../common'
import { Topic } from '../../common/topics'
import { IResponse } from '../../../../interfaces'
import { ObjectType, Field } from 'type-graphql'

@ObjectType()
class TextResponse extends Response(Text) {}

@ObjectType()
class TextsResponse extends Response(Text) {
  @Field(type => [String], { nullable: true })
  data: string[] | null
}

@Resolver()
export class TextResolver {
  constructor(
    private readonly textService: TextService,
    private readonly authService: AuthService
  ) {}

  @Query(returns => TextResponse)
github magishift / magishift.core / example / modules / packet / tender / participant / participant.dto.ts View on Github external
import { VENDOR_ENDPOINT } from '../../../vendor/interfaces/vendor.const';
import { IVendorDto } from '../../../vendor/interfaces/vendor.interface';
import { VendorDto } from '../../../vendor/vendor.dto';
import { ITenderDto } from '../interfaces/tender.interface';
import { PARTICIPANT_ENDPOINT } from './interfaces/participant.const';
import { IParticipantDto, ParticipantStatus } from './interfaces/participant.interface';

const ParticipantStep = {
  doc: { title: '1. Uploaded Qualification Document', order: 0 },
  result: { title: '2. Review Document', order: 1 },
  score: { title: '3. Score', order: 2 },
};

@Grid()
@Form({ type: FormTypes.Wizard })
@ObjectType(PARTICIPANT_ENDPOINT)
@InputType()
export class ParticipantDto extends CrudDto implements IParticipantDto {
  @FormFieldFk({
    fk: { tender: 'id' },
  })
  tender: ITenderDto;

  @Field(() => VendorDto)
  @IsInstance(VendorDto)
  @ApiModelProperty()
  @FormField({
    label: 'Participant',
    type: FieldTypes.Autocomplete,
    dataSource: { url: VENDOR_ENDPOINT, searchParams: ['companyName'] },
    wizardStep: ParticipantStep.doc,
  })