Skip to content

Commit

Permalink
fix: graphql resolver return type
Browse files Browse the repository at this point in the history
  • Loading branch information
Sairyss committed Dec 11, 2022
1 parent 6919d14 commit a1e2384
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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());
}
}

0 comments on commit a1e2384

Please sign in to comment.