Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@Field(type => String, { nullable: true })
name: string;
}
@ObjectType({ description: 'Article data with related Author data' })
class Article {
@Field(type => String)
title: string;
@Field(type => String, { nullable: true })
text: string;
@Field(type => ID)
authorId: number;
@Field(type => Author)
get author(): ?Object {
return authors.find(o => o.id === this.authorId);
}
}
@Resolver(of => Article)
class ArticleResolver implements ResolverInterface<article> {
@Query(returns => [Article])
// SyntaxError: Stage 2 decorators cannot be used to decorate parameters (36:17)
// Waiting fresh Babel implementation for decorators plugin
async articles(@Arg('limit') limit: string): Array<article> {
return articles.slice(0, limit);
}
}
</article></article>
@Column()
content: string;
@Field(type => ObjectID)
@Column()
authorId: ObjectID;
@Field(type => ObjectID)
@Column()
roomId: ObjectID;
@Field(type => [Embed])
@Column(type => Embed)
embeds: Embed[];
@Field()
createdAt(): Date {
return this.id.getTimestamp();
}
}
if (this.movementVec.modulus() > MaxSpeedVector.modulus()) {
this.movementVec = this.movementVec
.toUnitVector()
.multiply(MaxSpeedVector.modulus());
}
}
@Field()
get position(): Vector {
return {
x: this.positionVec.e(1),
y: this.positionVec.e(2)
};
}
@Field()
get velocity(): Vector {
return {
x: this.movementVec.e(1),
y: this.movementVec.e(2)
};
}
@Field()
get angle(): number {
return (
new Sylvester.Vector([1, 0]).angleTo(this.rotationVec) * 57.2957795 + 90
);
}
@Field()
get thrusting(): boolean {
import { AbilityScoreUpdate } from '@tabletop-companion/api-interface';
import { IsNotEmpty, IsNumber, IsString, Max, Min } from 'class-validator';
import { Field, InputType } from 'type-graphql';
import { typeInt } from '../../models';
import { IsCustomId } from '../../validators';
@InputType()
export class AbilityScoreUpdateDTO implements AbilityScoreUpdate {
@Field()
@IsCustomId('ABL')
@IsNotEmpty()
@IsString()
id!: string;
@Field(typeInt)
@Max(20)
@Min(0)
@IsNumber()
@IsNotEmpty()
value!: number;
}
export function BooleanField(args: BooleanFieldOptions = {}): any {
const options = { ...decoratorDefaults, ...args };
const nullableOption = options.nullable === true ? { nullable: true } : {};
const defaultOption =
options.default === true || options.default === false ? { default: options.default } : {};
const factories = [
WarthogField('boolean', options),
Field(() => GraphQLBoolean, {
...nullableOption,
...defaultOption
}),
Column({
type: 'boolean',
...nullableOption,
...defaultOption
}) as MethodDecoratorFactory
];
return composeMethodDecorators(...factories);
}
@Field()
bond!: string;
@Field()
flaw!: string;
@Field(typeStrings)
personalityTraits!: string[];
@Field(typeStrings)
proficiencies!: string[];
@Field(typeStrings)
languages!: string[];
@Field(typeString)
game = 'dd5';
}
export function ConnectionType(
TItemClass: ClassType,
Edge: TypeValue,
) {
@ObjectType({ isAbstract: true })
abstract class Connection implements Relay.Connection {
@Field()
pageInfo!: PageInfo;
@Field(() => [Edge])
edges!: Array>;
}
return Connection;
}
@Field(() => ID, { nullable: false })
id: string;
}
@ArgsType()
class FilterResolver extends Filter {
@Field(() => GraphQLJSONObject, { nullable: true })
where?: Partial;
@Field(() => GraphQLJSONObject, { nullable: true })
whereOr?: Partial;
}
@ObjectType(`${nameCapFirst}FindAll`)
class FindAllResult implements IFindAllResult {
@Field(() => Int)
totalCount: number;
@Field(() => [dtoClass])
items: TDto[];
}
@Resolver(() => dtoClass, { isAbstract: true })
@UseInterceptors(ClassSerializerInterceptor)
class CrudResolver implements ICrudResolver {
constructor(
protected readonly service: ICrudService,
protected readonly mapper: ICrudMapper,
protected readonly pubSub: PubSub,
) {}
@Query(() => dtoClass, { name: findById })