Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Labels
Plan
Issues
25
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
"git@gitlab.coko.foundation:yannis/editoria.git" did not exist on "d5f48b71a6d5249e879334618218067f37bd724f"
Show more breadcrumbs
cokoapps
server
Commits
358d8faf
Commit
358d8faf
authored
4 years ago
by
Giannis Kopanas
Browse files
Options
Downloads
Patches
Plain Diff
fix(server): add error handling for graphql errors
parent
3cbc97bf
No related branches found
No related tags found
1 merge request
!9
fix(server): add error handling for graphql errors
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/graphqlApi.js
+8
-2
8 additions, 2 deletions
src/graphqlApi.js
with
8 additions
and
2 deletions
src/graphqlApi.js
+
8
−
2
View file @
358d8faf
const
{
ApolloServer
}
=
require
(
'
apollo-server-express
'
)
const
{
ApolloServer
,
ForbiddenError
,
UserInputError
,
AuthenticationError
,
ApolloError
}
=
require
(
'
apollo-server-express
'
)
const
isEmpty
=
require
(
'
lodash/isEmpty
'
)
const
isEmpty
=
require
(
'
lodash/isEmpty
'
)
const
config
=
require
(
'
config
'
)
const
config
=
require
(
'
config
'
)
...
@@ -44,13 +44,19 @@ const api = app => {
...
@@ -44,13 +44,19 @@ const api = app => {
pubsweetError
=>
error
instanceof
pubsweetError
,
pubsweetError
=>
error
instanceof
pubsweetError
,
)
)
const
isGraphqlDefinedError
=
[
ForbiddenError
,
UserInputError
,
AuthenticationError
,
ApolloError
].
some
(
graphqlError
=>
error
instanceof
graphqlError
)
// err is always a GraphQLError which should be passed to the client
// err is always a GraphQLError which should be passed to the client
if
(
!
isEmpty
(
err
.
originalError
)
&&
!
isPubsweetDefinedError
)
if
(
!
isEmpty
(
err
.
originalError
)
&&
!
isPubsweetDefinedError
&&
!
isGraphqlDefinedError
)
return
{
return
{
name
:
'
Server Error
'
,
name
:
'
Server Error
'
,
message
:
'
Something went wrong! Please contact your administrator
'
,
message
:
'
Something went wrong! Please contact your administrator
'
,
}
}
if
(
isGraphqlDefinedError
)
return
error
return
{
return
{
name
:
error
.
name
||
'
GraphQLError
'
,
name
:
error
.
name
||
'
GraphQLError
'
,
message
:
error
.
message
,
message
:
error
.
message
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment