fix: graphql resolver return type

This commit is contained in:
user
2022-12-11 12:13:31 +01:00
parent 6919d14171
commit a1e2384a3f

View File

@@ -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<IdGqlResponse> {
const command = new CreateUserCommand(input);
const id = await this.commandBus.execute(command);
const id: Result<AggregateID, UserAlreadyExistsError> =
await this.commandBus.execute(command);
return new IdGqlResponse(id);
return new IdGqlResponse(id.unwrap());
}
}