@nestjs/graphql#ObjectType TypeScript Examples
The following examples show how to use
@nestjs/graphql#ObjectType.
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: cat.ts From nestjs-mercurius with MIT License | 6 votes |
@ObjectType({
implements: [Animal],
})
export class Cat implements Animal {
@Field(() => ID)
id: number;
@Directive('@uppercase')
@Field()
name: string;
@Field(() => Species)
species: Species;
@Field(() => Int)
lives: number;
}
Example #2
Source File: id.response.dto.ts From domain-driven-hexagon with MIT License | 6 votes |
@ObjectType() // <- only if you are using GraphQL
export class IdResponse implements Id {
constructor(id: string) {
this.id = id;
}
@ApiProperty({ example: '2cdc8ab1-6d50-49cc-ba14-54e4ac7ec231' })
@Field() // <- only if you are using GraphQL
readonly id: string;
}
Example #3
Source File: tag.entity.ts From whispr with MIT License | 6 votes |
@ObjectType()
export class Tag {
@Field(() => ID)
_id: string;
@Field(() => String)
title: string;
@Field(() => String, { defaultValue: TagStatuses.ACTIVE })
status: TagStatuses;
// @Field(() => String)
// tagGroupId: string;
@Field(() => TagGroup)
tagGroup: TagGroup;
}
Example #4
Source File: UserInfo.ts From amplication with Apache License 2.0 | 6 votes |
@ObjectType()
export class UserInfo implements Partial<User> {
@Field(() => String)
username!: string;
@Field(() => [String])
roles!: string[];
@Field(() => String, { nullable: true })
accessToken?: string;
}
Example #5
Source File: post.dto.ts From nest-casl with MIT License | 6 votes |
@ObjectType()
export class Post {
@Field()
id: string;
@Field()
userId: string;
@Field({ nullable: true })
title?: string;
}
Example #6
Source File: notification.model.ts From aws-nestjs-starter with The Unlicense | 6 votes |
@ObjectType({ implements: CreateNotificationInput })
export class Notification extends CreateNotificationInput {
@Field(/* istanbul ignore next */ () => ID)
id: string;
@Field(/* istanbul ignore next */ () => NotificationStatus)
status: NotificationStatus;
@Field()
createAt: string;
}
Example #7
Source File: db.types.ts From relate with GNU General Public License v3.0 | 6 votes |
@ObjectType()
export class Db {
@Field(() => String)
name: string;
@Field(() => String)
role: string;
@Field(() => String)
requestedStatus: string;
@Field(() => String)
currentStatus: string;
@Field(() => String)
error: string;
@Field(() => Boolean)
default: boolean;
}
Example #8
Source File: esrb-rating.entity.ts From game-store-monorepo-app with MIT License | 6 votes |
@ObjectType()
export class EsrbRating {
@Field((type) => Int)
id: number;
@Field({ nullable: true })
name?: string;
@Field({ nullable: true })
slug?: string;
}
Example #9
Source File: auth.jwt.model.ts From api with GNU Affero General Public License v3.0 | 6 votes |
@ObjectType('AuthToken')
export class AuthJwtModel {
@Field()
readonly accessToken: string
@Field()
readonly refreshToken: string
constructor(partial: Partial<AuthJwtModel>) {
this.accessToken = partial.accessToken
this.refreshToken = partial.refreshToken
}
}
Example #10
Source File: connection-type.factory.ts From nestjs-relay with MIT License | 6 votes |
static create<T>(args: CreateConnectionTypeArgs): AnyConstructor<Relay.Connection<T>> {
const nodeType = args.nodeTypeFunc() as AnyConstructor;
@ObjectType(`${args.nodeTypeName}Edge`)
class Edge implements Relay.Edge<T> {
@Field(() => nodeType, {
nullable: true,
})
node!: T;
@Field(() => String)
cursor!: Relay.ConnectionCursor;
}
@ObjectType(`${args.nodeTypeName}Connection`)
class Connection implements Relay.Connection<T> {
@Field(() => [Edge], {
nullable: 'itemsAndList',
})
edges!: Edge[];
@Field(() => PageInfo)
pageInfo!: Relay.PageInfo;
}
return Connection;
}
Example #11
Source File: auth.schema.ts From NextJS-NestJS-GraphQL-Starter with MIT License | 6 votes |
@ObjectType()
export class Session extends Document {
@Field(() => ID, { nullable: false })
readonly _id: string;
@Field()
readonly userAgent: string;
@Field({ nullable: false })
readonly token: string;
@Field({ nullable: false })
readonly user: string;
}