Command handlers that return values
In this release we introduce the @Returns
decorator that allows you to define the return type of a command handler.
This value will be returned to the client through GraphQL, instead of just returning true
(that's left for the case of void
).
As an example:
@Command({
authorize: 'all',
})
export class CreateProduct {
public constructor(readonly sku: string, readonly price: number) {}
@Returns(String)
public static async handle(command: CreateProduct, register: Register): Promise<string> {
return "Product created!"
}
}
Learn more in the Booster documentation