Skip to content

Instantly share code, notes, and snippets.

@a-essawy
Created February 8, 2024 11:24
Show Gist options
  • Save a-essawy/87b378c757ab6f7d7ec28b6f8d7c7860 to your computer and use it in GitHub Desktop.
Save a-essawy/87b378c757ab6f7d7ec28b6f8d7c7860 to your computer and use it in GitHub Desktop.
room.dto.ts and it's generated schema
import {
Directive,
Field,
GraphQLISODateTime,
ID,
ObjectType,
registerEnumType,
} from '@nestjs/graphql';
import { IRoom, IRoomDatabaseEntity, RoomType } from '@core';
import { FilterableField, IDField } from '@ptc-org/nestjs-query-graphql';
import { UserDto } from './user-dto.directive';
@ObjectType()
@Directive('@key(fields: "id")')
export class RoomDto implements Omit<IRoom, keyof IRoomDatabaseEntity> {
@IDField(() => ID)
id: string;
@FilterableField()
title: string;
@FilterableField(() => String, { nullable: true })
description?: string;
@FilterableField(() => RoomType)
roomType: RoomType;
@Field(() => [String])
resourceIds: string[];
@FilterableField(() => GraphQLISODateTime)
createdAt: Date;
@FilterableField(() => GraphQLISODateTime)
updatedAt: Date;
@Field(() => UserDto)
author: UserDto;
@Field(() => [UserDto])
participants: UserDto[];
@Field(() => [UserDto])
owners: UserDto[];
@Field(() => [UserDto])
moderators: UserDto[];
@Field(() => [UserDto])
collaborators: UserDto[];
}
registerEnumType(RoomType, {
name: 'RoomType',
});
####################################################################################
# ------------------------------------------------------
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
# ------------------------------------------------------
type UserDto {
id: ID!
rooms: [RoomDto!]!
moderatedRooms: [RoomDto!]!
participatedRooms: [RoomDto!]!
collaboratedRooms: [RoomDto!]!
}
type RoomDto {
id: ID!
title: String!
description: String
roomType: RoomType!
resourceIds: [String!]!
createdAt: DateTime!
updatedAt: DateTime!
author: UserDto!
participants: [UserDto!]!
owners: [UserDto!]!
moderators: [UserDto!]!
collaborators: [UserDto!]!
}
enum RoomType {
PUBLIC
PRIVATE
}
"""
A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format.
"""
scalar DateTime
type DeleteResponse {
message: String!
success: Boolean!
}
type Query {
room(id: String!): RoomDto!
rooms: [RoomDto!]!
}
type Mutation {
createRoom(room: CreateRoomInput!): RoomDto!
deleteRoom(id: String!): DeleteResponse!
}
"""Input to create a new room"""
input CreateRoomInput {
description: String
title: String!
roomType: String
resourceIds: [String!]!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment