Skip to content

Commit ac0b8d5

Browse files
committed
change error handlign syntax to apollo v4 standards
1 parent 3d8299b commit ac0b8d5

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
},
127127
"homepage": "https://github.com/open-source-labs/ReacType#readme",
128128
"dependencies": {
129-
"@apollo/client": "^3.6.9",
129+
"@apollo/client": "^3.7.10",
130130
"@apollo/federation": "^0.38.1",
131131
"@apollo/server": "^4.4.1",
132132
"@babel/cli": "^7.18.10",
@@ -158,7 +158,6 @@
158158
"fs": "^0.0.1-security",
159159
"graphql": "^16.6.0",
160160
"identity-obj-proxy": "^3.0.0",
161-
"immutable": "^4.1.0",
162161
"js-cookie": "^3.0.1",
163162
"localforage": "^1.10.0",
164163
"lodash": "^4.17.21",

server/graphQL/resolvers/mutation.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
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+
26
const { Projects, Users, Comments } = require('../../models/reactypeModels');
7+
38
/*
49
* resolvers are functions that handles graphQL requests. This file defines the logic for graphQL mutation requests
510
* Link to Apollo Mutations:
@@ -23,7 +28,7 @@ const Project = {
2328
});
2429
}
2530

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', {
2732
argumentName: 'projId',
2833
});
2934
},
@@ -33,7 +38,7 @@ const Project = {
3338
const target = await Projects.findOne(filter);
3439

3540
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', {
3742
argumentName: 'projId',
3843
});
3944
}
@@ -63,10 +68,10 @@ const Project = {
6368
});
6469
}
6570

66-
throw new UserInputError('Internal Server Error');
71+
throw new ApolloServerErrorCode.BAD_USER_INPUT('Internal Server Error');
6772
}
6873

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', {
7075
argumentName: 'userId',
7176
});
7277
},
@@ -87,7 +92,7 @@ const Project = {
8792
});
8893
}
8994

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', {
9196
argumentName: 'projId',
9297
});
9398
},
@@ -109,7 +114,7 @@ const Project = {
109114
});
110115
}
111116

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', {
113118
argumentName: 'projId',
114119
});
115120
},
@@ -145,7 +150,7 @@ const Project = {
145150
});
146151
}
147152

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', {
149154
argumentName: 'projId',
150155
});
151156
},

0 commit comments

Comments
 (0)