It seems I like the strong-typed languages. They make pictures clear.
The method destroy
of the class instance
returns the deleted instance forward. But at the package @types/sequelize
it is declared that it returns Promise<void>
. So I am not able use this declaration style below.
resolve: (_, args: {id: number}, request: ITokenizedRequest): Promise<IPersonInstance> => {
return PersonModel.findById(args.id)
.then((person: IPersonInstance): Promise<IPersonInstance> => {
return person.destroy();
});
}
Now it looks like below. But It does not show the whole picture.
export let deletePersonMutation: GraphQLFieldConfig<any, IPersonAttribute> = {
type: Person,
args: {
id: {
type: new GraphQLNonNull(GraphQLInt)
}
},
resolve: (_, args: {id: number}, request: ITokenizedRequest) => {
return PersonModel.findById(args.id)
.then((person: IPersonInstance) => {
return person.destroy();
});
}
};
Thank you.
via viktor.likin
No comments:
Post a Comment