@nestjs/graphql#InterfaceType TypeScript Examples

The following examples show how to use @nestjs/graphql#InterfaceType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: animal.interface.ts    From nestjs-mercurius with MIT License 6 votes vote down vote up
@InterfaceType({
  resolveType(animal) {
    switch (animal.species) {
      case Species.DOG:
        return import('./types/dog').then((module) => module.Dog);
      case Species.CAT:
        return import('./types/cat').then((module) => module.Cat);
    }
  },
})
export class Animal {
  @Field(() => ID)
  id: number;

  @Field(() => Species)
  species: Species;
}
Example #2
Source File: person.interface.ts    From nestjs-mercurius with MIT License 6 votes vote down vote up
@InterfaceType('IPerson')
export abstract class Person {
  @Field(() => ID)
  id: string;

  @Directive('@uppercase')
  @Field(() => String, { nullable: true })
  name?: string;
}
Example #3
Source File: IEntityPageSettings.ts    From amplication with Apache License 2.0 6 votes vote down vote up
@InterfaceType({ isAbstract: true })
@InputType({ isAbstract: true })
export abstract class IEntityPageSettings {
  @Field(() => Boolean, {
    nullable: false,
    description: undefined
  })
  allowCreation!: boolean;

  @Field(() => Boolean, {
    nullable: false,
    description: undefined
  })
  allowDeletion!: boolean;
}
Example #4
Source File: node.interface.ts    From nestjs-relay with MIT License 6 votes vote down vote up
@InterfaceType('Node', {
  description: 'An object with an ID',
})
export class NodeInterface {
  @Field({
    nullable: false,
    description: 'The ID of the object',
  })
  id!: ResolvedGlobalId;
}
Example #5
Source File: IBlock.ts    From amplication with Apache License 2.0 5 votes vote down vote up
@InterfaceType()
export abstract class IBlock {
  @Field(() => String, {
    nullable: false,
    description: undefined
  })
  id!: string;

  @Field(() => Date, {
    nullable: false,
    description: undefined
  })
  createdAt!: Date;

  appId?: string;

  @Field(() => Date, {
    nullable: false,
    description: undefined
  })
  updatedAt!: Date;

  @Field(() => Block, {
    nullable: true,
    description: undefined
  })
  parentBlock!: Block | null;

  @Field(() => String, {
    nullable: false,
    description: undefined
  })
  displayName!: string;

  @Field(() => String, {
    nullable: false,
    description: undefined
  })
  description!: string;

  @Field(() => EnumBlockType, {
    nullable: false,
    description: undefined
  })
  blockType!: keyof typeof EnumBlockType;

  @Field(() => Number, {
    nullable: false,
    description: undefined
  })
  versionNumber!: number;

  @Field(() => [BlockInputOutput], {
    nullable: false,
    description: undefined
  })
  inputParameters!: BlockInputOutput[];

  @Field(() => [BlockInputOutput], {
    nullable: false,
    description: undefined
  })
  outputParameters!: BlockInputOutput[];

  @Field(() => String, {
    nullable: true,
    description: undefined
  })
  lockedByUserId?: string;

  @Field(() => Date, {
    nullable: true,
    description: undefined
  })
  lockedAt?: Date;
}