11import { makeExecutableSchema , gql } from "apollo-server-express" ;
22import { applyMiddleware } from "graphql-middleware" ;
33import { merge } from "lodash" ;
4+ import { GraphQLScalarType , Kind } from "graphql" ;
45
56import {
67 isAuthorizedByEmail ,
@@ -20,6 +21,8 @@ import dashboardResolvers from "./resolvers/dashboardResolvers";
2021import reviewType from "./types/reviewType" ;
2122import reviewDashboardResolvers from "./resolvers/reviewDashboardResolvers" ;
2223import reviewDashboardType from "./types/reviewDashboardType" ;
24+ import reviewedApplicantRecordTypes from "./types/reviewedApplicantRecordTypes" ;
25+ import reviewedApplicantRecordResolvers from "./resolvers/reviewedApplicantRecordResolver" ;
2326
2427const 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+
3669const 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 ( ) ,
0 commit comments