Skip to content

Commit 3b70eeb

Browse files
use Review type in graphQL schema
1 parent f9e0422 commit 3b70eeb

File tree

2 files changed

+25
-42
lines changed

2 files changed

+25
-42
lines changed

backend/typescript/graphql/index.ts

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { makeExecutableSchema, gql } from "apollo-server-express";
22
import { applyMiddleware } from "graphql-middleware";
33
import { merge } from "lodash";
4-
import { GraphQLScalarType, Kind } from "graphql";
54

65
import {
76
isAuthorizedByEmail,
@@ -37,54 +36,20 @@ const mutation = gql`
3736
}
3837
`;
3938

40-
const scalarTypes = gql`
41-
scalar JSON
42-
`;
43-
44-
const JSONScalar = new GraphQLScalarType({
45-
name: "JSON",
46-
description: "JSON scalar type",
47-
serialize: (value) => value,
48-
parseValue: (value) => value,
49-
parseLiteral: (ast) => {
50-
switch (ast.kind) {
51-
case Kind.STRING:
52-
case Kind.BOOLEAN:
53-
return ast.value;
54-
case Kind.INT:
55-
case Kind.FLOAT:
56-
return parseFloat(ast.value);
57-
case Kind.OBJECT:
58-
return ast.fields.reduce((obj: any, field: any) => {
59-
obj[field.name.value] = JSONScalar.parseLiteral(field.value, {});
60-
return obj;
61-
}, {});
62-
case Kind.LIST:
63-
return ast.values.map((value: any) => JSONScalar.parseLiteral(value, {}));
64-
default:
65-
return null;
66-
}
67-
},
68-
});
69-
7039
const executableSchema = makeExecutableSchema({
7140
typeDefs: [
7241
query,
7342
mutation,
74-
scalarTypes,
7543
authType,
7644
entityType,
7745
simpleEntityType,
7846
userType,
7947
reviewDashboardType,
80-
reviewedApplicantRecordTypes
48+
reviewedApplicantRecordTypes,
8149
adminCommentType,
8250
reviewPageType,
8351
],
8452
resolvers: merge(
85-
{
86-
JSON: JSONScalar,
87-
},
8853
authResolvers,
8954
entityResolvers,
9055
simpleEntityResolvers,
@@ -118,10 +83,6 @@ const graphQLMiddlewares = {
11883
createSimpleEntity: authorizedByAllRoles(),
11984
updateSimpleEntity: authorizedByAllRoles(),
12085
deleteSimpleEntity: authorizedByAllRoles(),
121-
changeRating: authorizedByAllRoles(),
122-
changeSkillCategory: authorizedByAllRoles(),
123-
updateApplications: authorizedByAllRoles(),
124-
modifyFinalComments: authorizedByAllRoles(),
12586
createReviewedApplicantRecord: authorizedByAllRoles(),
12687
bulkCreateReviewedApplicantRecord: authorizedByAllRoles(),
12788
deleteReviewedApplicantRecord: authorizedByAllRoles(),

backend/typescript/graphql/types/reviewedApplicantRecordTypes.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
import { gql } from "apollo-server-express";
22

33
const reviewedApplicantRecordTypes = gql`
4+
enum SkillCategory {
5+
JUNIOR
6+
INTERMEDIATE
7+
SENIOR
8+
}
9+
10+
type Review {
11+
passionFSG: Int
12+
teamPlayer: Int
13+
desireToLearn: Int
14+
skill: Int
15+
skillCategory: SkillCategory
16+
}
17+
18+
input ReviewInput {
19+
passionFSG: Int
20+
teamPlayer: Int
21+
desireToLearn: Int
22+
skill: Int
23+
skillCategory: SkillCategory
24+
}
25+
426
type ReviewedApplicantRecord {
527
applicantRecordId: ID!
628
reviewerId: Int!
7-
review: JSON
29+
review: Review
830
status: String
931
score: Int
1032
reviewerHasConflict: Boolean
@@ -13,7 +35,7 @@ const reviewedApplicantRecordTypes = gql`
1335
input CreateReviewedApplicantRecordInput {
1436
applicantRecordId: ID!
1537
reviewerId: Int!
16-
review: JSON
38+
review: ReviewInput
1739
status: String
1840
}
1941

0 commit comments

Comments
 (0)