Last active
February 8, 2024 11:28
-
-
Save a-essawy/a3d4c2ef5bab8211ddd5597b5898e2d3 to your computer and use it in GitHub Desktop.
user.dto.ts and it's generated schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, ID, ObjectType, registerEnumType } from '@nestjs/graphql'; | |
import { FilterableField, IDField } from '@ptc-org/nestjs-query-graphql'; | |
import { IUser, UserRole } from '@core'; | |
@ObjectType() | |
@Directive('@key(fields: "id")') | |
export class UserDto implements Omit<IUser, 'password' | 'hashedRefreshToken'> { | |
@IDField(() => ID) | |
id: string; | |
@FilterableField(() => String) | |
firstName: string; | |
@FilterableField() | |
lastName: string; | |
@FilterableField() | |
username: string; | |
@FilterableField() | |
email: string; | |
@FilterableField() | |
verified: boolean; | |
@FilterableField({ | |
nullable: true, | |
}) | |
birthday?: Date; | |
@FilterableField(() => UserRole) | |
role: UserRole; | |
@FilterableField() | |
createdAt: Date; | |
@FilterableField() | |
updatedAt: Date; | |
constructor(user: UserDto) { | |
Object.assign(this, user); | |
} | |
} | |
registerEnumType(UserRole, { | |
name: 'UserRole', | |
}); | |
################################################################################################### | |
# ------------------------------------------------------ | |
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) | |
# ------------------------------------------------------ | |
type UserDto { | |
id: ID! | |
firstName: String! | |
lastName: String! | |
username: String! | |
email: String! | |
verified: Boolean! | |
birthday: DateTime | |
role: UserRole! | |
createdAt: DateTime! | |
updatedAt: DateTime! | |
} | |
""" | |
A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format. | |
""" | |
scalar DateTime | |
enum UserRole { | |
ADMIN | |
USER | |
} | |
"""Login response""" | |
type LoginResponseDto { | |
accessToken: String! | |
refreshToken: String! | |
user: UserDto! | |
} | |
"""Register response""" | |
type RegisterResponse { | |
accessToken: String! | |
refreshToken: String! | |
user: UserDto! | |
} | |
type Query { | |
me: UserDto! | |
} | |
type Mutation { | |
"""Login a user with username or email and password, returns JWT token.""" | |
login(credentials: Credentials!): LoginResponseDto! | |
register(userInfo: RegisterUserDto!): RegisterResponse! | |
refreshToken: LoginResponseDto! | |
} | |
"""Login user""" | |
input Credentials { | |
email: String | |
username: String | |
password: String! | |
} | |
"""Create new user""" | |
input RegisterUserDto { | |
email: String! | |
firstName: String! | |
password: String! | |
lastName: String! | |
username: String! | |
birthday: DateTime | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment