Skip to content

Commit a462dbe

Browse files
fixed typescript errors
1 parent 2596b8d commit a462dbe

File tree

5 files changed

+41
-31
lines changed

5 files changed

+41
-31
lines changed
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { prismaObjectType, interfaceType } from 'yoga'
1+
import { prismaObjectType } from 'yoga'
22

33

44
export const Mutation = prismaObjectType({
@@ -11,14 +11,3 @@ export const Mutation = prismaObjectType({
1111
t.prismaFields([])
1212
},
1313
})
14-
15-
export const PayloadInterface = interfaceType({
16-
name: "PayloadInterface",
17-
description: "The standard interface for all mutation responses",
18-
definition: (t) => {
19-
t.string("code");
20-
t.boolean("success");
21-
t.string("message");
22-
t.resolveType(() => null);
23-
}
24-
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { interfaceType } from "yoga";
2+
3+
export const PayloadInterface = interfaceType({
4+
name: "PayloadInterface",
5+
description: "The standard interface for all mutation responses",
6+
definition: (t) => {
7+
t.string("code", {
8+
nullable: true
9+
});
10+
t.boolean("success");
11+
t.string("message", {
12+
nullable: true
13+
});
14+
t.resolveType(() => null);
15+
}
16+
})

packages/server/src/graphql/Query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { prismaObjectType, stringArg } from 'yoga'
1+
import { prismaObjectType } from 'yoga'
22

33

44
export const Query = prismaObjectType({

packages/server/src/graphql/UserTutorial.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { prismaObjectType, objectType, mutationField, idArg } from 'yoga'
2-
import { getUserId } from '../utils';
2+
// import { getUserId } from '../utils';
3+
import { PayloadInterface } from './PayloadInterface';
34

45
export const UserTutorial = prismaObjectType({
56
name: 'UserTutorial',
@@ -13,9 +14,10 @@ export const UserTutorial = prismaObjectType({
1314
export const UserTutorialPayload = objectType({
1415
name: "UserTutorialPayload",
1516
definition: (t) => {
16-
t.implements("PayloadInterface");
17+
t.implements(PayloadInterface);
1718
t.field("userTutorial", {
18-
type: UserTutorial
19+
type: UserTutorial,
20+
nullable: true
1921
});
2022
}
2123
})
@@ -29,13 +31,12 @@ export const upvote = mutationField("upvote", {
2931
})
3032
},
3133
resolve: async (parent, args, ctx) => {
32-
const currentUserId = getUserId(ctx);
34+
// const currentUserId = getUserId(ctx);
3335
return ({
3436
code: "200",
3537
success: true,
36-
userTutorial: {
37-
id: "123"
38-
}
38+
message: null,
39+
userTutorial: null
3940
})
4041
}
4142
})

packages/server/src/graphql/auth.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@ import { getGithubToken, getGithubUser, GithubUser } from '../github';
44
import { Context } from "../context";
55
import { User } from "../../.yoga/prisma-client";
66
import config from "../config";
7+
import { PayloadInterface } from "./PayloadInterface";
8+
9+
export const AuthenticateUserPayload = objectType({
10+
name: "AuthenticateUserPayload",
11+
definition: (t) => {
12+
t.implements(PayloadInterface);
13+
t.field("user", {
14+
type: "User"
15+
})
16+
t.string("token")
17+
}
18+
})
719

820
export const authenticate = mutationField("authenticate", {
9-
type: "AuthenticateUserPayload",
21+
type: AuthenticateUserPayload,
1022
nullable: true,
1123
args: {
1224
githubCode: stringArg({
@@ -25,22 +37,14 @@ export const authenticate = mutationField("authenticate", {
2537

2638
return {
2739
success: true,
40+
message: null,
41+
code: null,
2842
token: jwt.sign({ userId: user.id }, config.jwt.SECRET),
2943
user
3044
}
3145
}
3246
})
3347

34-
export const AuthenticateUserPayload = objectType({
35-
name: "AuthenticateUserPayload",
36-
definition: (t) => {
37-
t.implements("PayloadInterface");
38-
t.field("user", {
39-
type: "User"
40-
})
41-
t.string("token")
42-
}
43-
})
4448
// Helpers -------------------------------------------------------------------
4549

4650
async function getPrismaUser(ctx: Context, githubUserId: string): Promise<User> {

0 commit comments

Comments
 (0)