Skip to content

Commit ff42da4

Browse files
debugging
1 parent b8b9a8f commit ff42da4

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

backend/typescript/graphql/index.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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";
45

56
import {
67
isAuthorizedByEmail,
@@ -20,6 +21,8 @@ import dashboardResolvers from "./resolvers/dashboardResolvers";
2021
import reviewType from "./types/reviewType";
2122
import reviewDashboardResolvers from "./resolvers/reviewDashboardResolvers";
2223
import reviewDashboardType from "./types/reviewDashboardType";
24+
import reviewedApplicantRecordTypes from "./types/reviewedApplicantRecordTypes";
25+
import reviewedApplicantRecordResolvers from "./resolvers/reviewedApplicantRecordResolver";
2326

2427
const query = gql`
2528
type Query {
@@ -33,25 +36,61 @@ const mutation = gql`
3336
}
3437
`;
3538

39+
const scalarTypes = gql`
40+
scalar JSON
41+
`;
42+
43+
const JSONScalar = new GraphQLScalarType({
44+
name: "JSON",
45+
description: "JSON scalar type",
46+
serialize: (value) => value,
47+
parseValue: (value) => value,
48+
parseLiteral: (ast) => {
49+
switch (ast.kind) {
50+
case Kind.STRING:
51+
case Kind.BOOLEAN:
52+
return ast.value;
53+
case Kind.INT:
54+
case Kind.FLOAT:
55+
return parseFloat(ast.value);
56+
case Kind.OBJECT:
57+
return ast.fields.reduce((obj: any, field: any) => {
58+
obj[field.name.value] = JSONScalar.parseLiteral(field.value, {});
59+
return obj;
60+
}, {});
61+
case Kind.LIST:
62+
return ast.values.map((value: any) => JSONScalar.parseLiteral(value, {}));
63+
default:
64+
return null;
65+
}
66+
},
67+
});
68+
3669
const executableSchema = makeExecutableSchema({
3770
typeDefs: [
3871
query,
3972
mutation,
73+
scalarTypes,
4074
authType,
4175
reviewType,
4276
entityType,
4377
simpleEntityType,
4478
userType,
4579
dashboardType,
4680
reviewDashboardType,
81+
reviewedApplicantRecordTypes
4782
],
4883
resolvers: merge(
84+
{
85+
JSON: JSONScalar,
86+
},
4987
authResolvers,
5088
entityResolvers,
5189
simpleEntityResolvers,
5290
userResolvers,
5391
dashboardResolvers,
5492
reviewDashboardResolvers,
93+
reviewedApplicantRecordResolvers,
5594
),
5695
});
5796

@@ -87,6 +126,10 @@ const graphQLMiddlewares = {
87126
changeSkillCategory: authorizedByAllRoles(),
88127
updateApplications: authorizedByAllRoles(),
89128
modifyFinalComments: authorizedByAllRoles(),
129+
createReviewedApplicantRecord: authorizedByAllRoles(),
130+
bulkCreateReviewedApplicantRecord: authorizedByAllRoles(),
131+
deleteReviewedApplicantRecord: authorizedByAllRoles(),
132+
bulkDeleteReviewedApplicantRecord: authorizedByAllRoles(),
90133
createUser: authorizedByAdmin(),
91134
updateUser: authorizedByAdmin(),
92135
deleteUserById: authorizedByAdmin(),

backend/typescript/graphql/types/reviewedApplicantRecordTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const reviewedApplicantRecordTypes = gql`
1717
status: String
1818
}
1919
20-
type Mutation {
20+
extend type Mutation {
2121
createReviewedApplicantRecord(
2222
input: CreateReviewedApplicantRecordInput!
2323
): ReviewedApplicantRecord!
@@ -37,5 +37,5 @@ const reviewedApplicantRecordTypes = gql`
3737
): [ReviewedApplicantRecord!]!
3838
}
3939
`;
40-
40+
4141
export default reviewedApplicantRecordTypes;

backend/typescript/models/reviewedApplicantRecord.model.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { Review, ReviewStatus, ReviewStatusEnum } from "../types";
1313
import ApplicantRecord from "./applicantRecord.model";
1414
import User from "./user.model";
1515

16-
@Table({ tableName: "reviewed_applicant_records" })
16+
@Table({
17+
tableName: "reviewed_applicant_records",
18+
timestamps: false
19+
})
1720
export default class ReviewedApplicantRecord extends Model {
1821
@ForeignKey(() => ApplicantRecord)
1922
@Column({ type: DataType.STRING, primaryKey: true })

0 commit comments

Comments
 (0)