1
- const { UserInputError } = require ( 'apollo-server-express' ) ;
1
+ // const { ApolloServerErrorCode.BAD_USER_INPUT } = require('apollo-server-express');
2
+
3
+ import { ApolloServerErrorCode } from '@apollo/server/errors' ; // v4 syntax
4
+ //now using ApolloServerErrorCode.BAD_USER_INPUT in place of ApolloServerErrorCode.BAD_USER_INPUT
5
+
2
6
const { Projects, Users, Comments } = require ( '../../models/reactypeModels' ) ;
7
+
3
8
/*
4
9
* resolvers are functions that handles graphQL requests. This file defines the logic for graphQL mutation requests
5
10
* Link to Apollo Mutations:
@@ -23,7 +28,7 @@ const Project = {
23
28
} ) ;
24
29
}
25
30
26
- throw new UserInputError ( 'Project is not found. Please try another project ID' , {
31
+ throw new ApolloServerErrorCode . BAD_USER_INPUT ( 'Project is not found. Please try another project ID' , {
27
32
argumentName : 'projId' ,
28
33
} ) ;
29
34
} ,
@@ -33,7 +38,7 @@ const Project = {
33
38
const target = await Projects . findOne ( filter ) ;
34
39
35
40
if ( ! target ) {
36
- throw new UserInputError ( 'Project is not found. Please try another project ID' , {
41
+ throw new ApolloServerErrorCode . BAD_USER_INPUT ( 'Project is not found. Please try another project ID' , {
37
42
argumentName : 'projId' ,
38
43
} ) ;
39
44
}
@@ -63,10 +68,10 @@ const Project = {
63
68
} ) ;
64
69
}
65
70
66
- throw new UserInputError ( 'Internal Server Error' ) ;
71
+ throw new ApolloServerErrorCode . BAD_USER_INPUT ( 'Internal Server Error' ) ;
67
72
}
68
73
69
- throw new UserInputError ( 'User is not found. Please try another user ID' , {
74
+ throw new ApolloServerErrorCode . BAD_USER_INPUT ( 'User is not found. Please try another user ID' , {
70
75
argumentName : 'userId' ,
71
76
} ) ;
72
77
} ,
@@ -87,7 +92,7 @@ const Project = {
87
92
} ) ;
88
93
}
89
94
90
- throw new UserInputError ( 'Project is not found. Please try another project ID' , {
95
+ throw new ApolloServerErrorCode . BAD_USER_INPUT ( 'Project is not found. Please try another project ID' , {
91
96
argumentName : 'projId' ,
92
97
} ) ;
93
98
} ,
@@ -109,7 +114,7 @@ const Project = {
109
114
} ) ;
110
115
}
111
116
112
- throw new UserInputError ( 'Project is not found. Please try another project ID' , {
117
+ throw new ApolloServerErrorCode . BAD_USER_INPUT ( 'Project is not found. Please try another project ID' , {
113
118
argumentName : 'projId' ,
114
119
} ) ;
115
120
} ,
@@ -145,7 +150,7 @@ const Project = {
145
150
} ) ;
146
151
}
147
152
148
- throw new UserInputError ( 'Project cannot be found. Please try another project ID' , {
153
+ throw new ApolloServerErrorCode . BAD_USER_INPUT ( 'Project cannot be found. Please try another project ID' , {
149
154
argumentName : 'projId' ,
150
155
} ) ;
151
156
} ,
0 commit comments