Skip to content

Commit 8a4715a

Browse files
committed
logout
1 parent 7983648 commit 8a4715a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/modules/user/Logout.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import {Resolver, Mutation, Ctx} from "type-graphql"
1+
import { Resolver, Mutation, Ctx } from "type-graphql"
22
import { MyContext } from "../../types/MyContext";
33

44
@Resolver()
55
export class LogoutResolver {
6-
@Mutation()
7-
async logout(@Ctx() context:MyContext) {
8-
context.req.session!.destroy(err => {
9-
if (err) {
10-
console.log(err)
11-
}
12-
});
6+
@Mutation(() => Boolean)
7+
async logout(@Ctx() context: MyContext): Promise<Boolean> {
8+
return new Promise(
9+
(res, rej) => context.req.session!.destroy(err => {
10+
if (err) {
11+
console.log(err);
12+
rej(false);
13+
}
14+
res(true);
15+
})
16+
);
1317
}
1418
}

0 commit comments

Comments
 (0)