From a1e2384a3fc52eefddcb2f8b2f59531543c1fd42 Mon Sep 17 00:00:00 2001 From: user Date: Sun, 11 Dec 2022 12:13:31 +0100 Subject: [PATCH] fix: graphql resolver return type --- .../graphql-example/create-user.graphql-resolver.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/user/commands/create-user/graphql-example/create-user.graphql-resolver.ts b/src/modules/user/commands/create-user/graphql-example/create-user.graphql-resolver.ts index 30f59757..85adcb45 100644 --- a/src/modules/user/commands/create-user/graphql-example/create-user.graphql-resolver.ts +++ b/src/modules/user/commands/create-user/graphql-example/create-user.graphql-resolver.ts @@ -3,6 +3,9 @@ import { CommandBus } from '@nestjs/cqrs'; import { CreateUserCommand } from '../create-user.command'; import { CreateUserGqlRequestDto } from './dtos/create-user.gql-request.dto'; import { IdGqlResponse } from './dtos/id.gql-response.dto'; +import { AggregateID } from '@src/libs/ddd'; +import { UserAlreadyExistsError } from '@src/modules/user/domain/user.errors'; +import { Result } from 'oxide.ts/dist'; // If you are Using GraphQL you'll need a Resolver instead of a Controller @Resolver() @@ -15,8 +18,9 @@ export class CreateUserGraphqlResolver { ): Promise { const command = new CreateUserCommand(input); - const id = await this.commandBus.execute(command); + const id: Result = + await this.commandBus.execute(command); - return new IdGqlResponse(id); + return new IdGqlResponse(id.unwrap()); } }