-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from apollo-errors to apollo-server-errors (#6200)
- Loading branch information
Showing
9 changed files
with
38 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@keystone-next/keystone': patch | ||
--- | ||
|
||
Updated internal error handling to use the `apollo-server-errors` package instead of `apollo-errors`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import { createError } from 'apollo-errors'; | ||
import { ApolloError } from 'apollo-server-errors'; | ||
|
||
export const AccessDeniedError = createError('AccessDeniedError', { | ||
message: 'You do not have access to this resource', | ||
options: { showPath: true }, | ||
}); | ||
export const ValidationFailureError = createError('ValidationFailureError', { | ||
message: 'You attempted to perform an invalid mutation', | ||
options: { showPath: true }, | ||
}); | ||
export const LimitsExceededError = createError('LimitsExceededError', { | ||
message: 'Your request exceeded server limits', | ||
options: { showPath: true }, | ||
}); | ||
export const accessDeniedError = () => new ApolloError('You do not have access to this resource'); | ||
|
||
export const accessDeniedError = ( | ||
type: 'query' | 'mutation', | ||
target?: string, | ||
internalData = {}, | ||
extraData = {} | ||
) => { | ||
return new AccessDeniedError({ data: { type, target, ...extraData }, internalData }); | ||
}; | ||
export const validationFailureError = () => | ||
new ApolloError('You attempted to perform an invalid mutation'); | ||
|
||
// FIXME: In an upcoming PR we will use these args to construct a better | ||
// error message, so leaving the, here for now. - TL | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export const limitsExceededError = (args: { type: string; limit: number; list: string }) => | ||
new ApolloError('Your request exceeded server limits'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
686c0f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: