From 1c433e2d57269ce9decdddf6f26c728f71413888 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 23 Aug 2022 11:53:19 +0200 Subject: [PATCH] Add graphql object that will be returned instead of dbEntity. --- .../src/graphql/model/ContributionMessage.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 backend/src/graphql/model/ContributionMessage.ts diff --git a/backend/src/graphql/model/ContributionMessage.ts b/backend/src/graphql/model/ContributionMessage.ts new file mode 100644 index 000000000..caf5eddc4 --- /dev/null +++ b/backend/src/graphql/model/ContributionMessage.ts @@ -0,0 +1,37 @@ +import { Field, ObjectType } from 'type-graphql' +import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' +import { User } from './User' + +@ObjectType() +export class ContributionMessage { + constructor(contributionMessage: DbContributionMessage, user: User) { + this.id = contributionMessage.id + this.message = contributionMessage.message + this.createdAt = contributionMessage.createdAt + this.updatedAt = contributionMessage.updatedAt + this.type = contributionMessage.type + this.userFirstName = user.firstName + this.userLastName = user.lastName + } + + @Field(() => Number) + id: number + + @Field(() => String) + message: string + + @Field(() => Date) + createdAt: Date + + @Field(() => Date, { nullable: true }) + updatedAt?: Date | null + + @Field(() => String) + type: string + + @Field(() => String, { nullable: true }) + userFirstName: string | null + + @Field(() => String, { nullable: true }) + userLastName: string | null +}