fix: graphql resolver return type
This commit is contained in:
@@ -3,6 +3,9 @@ import { CommandBus } from '@nestjs/cqrs';
|
|||||||
import { CreateUserCommand } from '../create-user.command';
|
import { CreateUserCommand } from '../create-user.command';
|
||||||
import { CreateUserGqlRequestDto } from './dtos/create-user.gql-request.dto';
|
import { CreateUserGqlRequestDto } from './dtos/create-user.gql-request.dto';
|
||||||
import { IdGqlResponse } from './dtos/id.gql-response.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
|
// If you are Using GraphQL you'll need a Resolver instead of a Controller
|
||||||
@Resolver()
|
@Resolver()
|
||||||
@@ -15,8 +18,9 @@ export class CreateUserGraphqlResolver {
|
|||||||
): Promise<IdGqlResponse> {
|
): Promise<IdGqlResponse> {
|
||||||
const command = new CreateUserCommand(input);
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user