Created
February 8, 2024 11:25
-
-
Save a-essawy/b5a1293345880f9845e3651c0e5babad to your computer and use it in GitHub Desktop.
resource.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, | |
Field, | |
GraphQLISODateTime, | |
ID, | |
ObjectType, | |
registerEnumType, | |
} from '@nestjs/graphql'; | |
import { FilterableField, IDField } from '@ptc-org/nestjs-query-graphql'; | |
import { IResource, ResourceFormat, ResourceType } from '@core'; | |
import { UserDto } from './user-refrence.dto'; | |
@ObjectType('Resource', { | |
description: 'Resources uploaded by users', | |
}) | |
@Directive('@key(fields: "id")') | |
export class ResourceDto implements IResource { | |
@IDField(() => ID) | |
id: string; | |
@FilterableField() | |
title: string; | |
@FilterableField() | |
description?: string; | |
@FilterableField(() => ResourceType) | |
type: ResourceType; | |
@FilterableField(() => ResourceFormat) | |
format: ResourceFormat; | |
@FilterableField(() => GraphQLISODateTime) | |
createdAt: Date; | |
@FilterableField(() => GraphQLISODateTime) | |
updatedAt: Date; | |
@Field(() => UserDto) | |
author: UserDto; | |
@Field(() => String, { | |
nullable: true, | |
}) | |
indexed: string; | |
@Field(() => String, { | |
nullable: true, | |
}) | |
raw: string; | |
} | |
registerEnumType(ResourceType, { | |
name: 'ResourceType', | |
}); | |
registerEnumType(ResourceFormat, { | |
name: 'ResourceFormat', | |
}); | |
#################################################################################### | |
# ------------------------------------------------------ | |
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) | |
# ------------------------------------------------------ | |
type UserDto { | |
id: ID! | |
resources: [Resource!]! | |
} | |
"""Resources uploaded by users""" | |
type Resource { | |
id: ID! | |
title: String! | |
description: String! | |
type: ResourceType! | |
format: ResourceFormat! | |
createdAt: DateTime! | |
updatedAt: DateTime! | |
author: UserDto! | |
indexed: String | |
raw: String | |
} | |
enum ResourceType { | |
BOOK | |
VIDEO | |
AUDIO | |
IMAGE | |
DOCUMENT | |
ARTICLE | |
CODE | |
OTHER | |
} | |
enum ResourceFormat { | |
DOC | |
DOCX | |
XLS | |
XLSX | |
PPT | |
PPTX | |
MP3 | |
MP4 | |
WAV | |
AVI | |
MKV | |
JPG | |
JPEG | |
PNG | |
GIF | |
OTHER | |
} | |
""" | |
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 { | |
getOneResource(id: String!): Resource! | |
getAllResources: [Resource!]! | |
} | |
type Mutation { | |
createResource(resource: CreateResourceInput!): Resource! | |
deleteResource(id: String!): DeleteResponse! | |
} | |
"""Create new resource""" | |
input CreateResourceInput { | |
description: String! | |
format: String! | |
title: String! | |
type: String! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment