File tree Expand file tree Collapse file tree 7 files changed +84
-1
lines changed Expand file tree Collapse file tree 7 files changed +84
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import { ApolloDriverConfig } from '../interfaces';
14
14
import { createAsyncIterator } from '../utils/async-iterator.util' ;
15
15
16
16
const apolloPredefinedExceptions : Partial < Record < HttpStatus , string > > = {
17
- [ HttpStatus . BAD_REQUEST ] : ApolloServerErrorCode . BAD_USER_INPUT ,
17
+ [ HttpStatus . BAD_REQUEST ] : ApolloServerErrorCode . BAD_REQUEST ,
18
18
[ HttpStatus . UNAUTHORIZED ] : 'UNAUTHENTICATED' ,
19
19
[ HttpStatus . FORBIDDEN ] : 'FORBIDDEN' ,
20
20
} ;
Original file line number Diff line number Diff line change
1
+ import { GraphQLError , GraphQLErrorOptions } from 'graphql' ;
2
+
3
+ /**
4
+ * This error is thrown when the user is not authenticated.
5
+ *
6
+ * "AuthenticationError" class was removed in the latest version of Apollo Server (4.0.0)
7
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
8
+ */
9
+ export class AuthenticationError extends GraphQLError {
10
+ constructor ( message : string , options ?: GraphQLErrorOptions ) {
11
+ super ( message , {
12
+ ...options ,
13
+ extensions : {
14
+ code : 'UNAUTHENTICATED' ,
15
+ ...options ?. extensions ,
16
+ } ,
17
+ } ) ;
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ import { GraphQLError , GraphQLErrorOptions } from 'graphql' ;
2
+
3
+ /**
4
+ * This error is thrown when the user is not authorized to access a resource.
5
+ *
6
+ * "ForbiddenError" class was removed in the latest version of Apollo Server (4.0.0)
7
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
8
+ */
9
+ export class ForbiddenError extends GraphQLError {
10
+ constructor ( message : string , options ?: GraphQLErrorOptions ) {
11
+ super ( message , {
12
+ ...options ,
13
+ extensions : {
14
+ code : 'FORBIDDEN' ,
15
+ ...options ?. extensions ,
16
+ } ,
17
+ } ) ;
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ export * from './authentication.error' ;
2
+ export * from './forbidden.error' ;
3
+ export * from './user-input.error' ;
4
+ export * from './validation.error' ;
Original file line number Diff line number Diff line change
1
+ import { ApolloServerErrorCode } from '@apollo/server/errors' ;
2
+ import { GraphQLError , GraphQLErrorOptions } from 'graphql' ;
3
+
4
+ /**
5
+ * This error is thrown when the user input is invalid.
6
+ *
7
+ * "UserInputError" class was removed in the latest version of Apollo Server (4.0.0)
8
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
9
+ */
10
+ export class UserInputError extends GraphQLError {
11
+ constructor ( message : string , options ?: GraphQLErrorOptions ) {
12
+ super ( message , {
13
+ ...options ,
14
+ extensions : {
15
+ code : ApolloServerErrorCode . BAD_USER_INPUT ,
16
+ ...options ?. extensions ,
17
+ } ,
18
+ } ) ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ import { ApolloServerErrorCode } from '@apollo/server/errors' ;
2
+ import { GraphQLError , GraphQLErrorOptions } from 'graphql' ;
3
+
4
+ /**
5
+ * This error is thrown when the user input does not pass validation.
6
+ *
7
+ * "ValidationError" class was removed in the latest version of Apollo Server (4.0.0)
8
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
9
+ */
10
+ export class ValidationError extends GraphQLError {
11
+ constructor ( message : string , options ?: GraphQLErrorOptions ) {
12
+ super ( message , {
13
+ ...options ,
14
+ extensions : {
15
+ code : ApolloServerErrorCode . GRAPHQL_VALIDATION_FAILED ,
16
+ ...options ?. extensions ,
17
+ } ,
18
+ } ) ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change 1
1
export * from './decorators' ;
2
2
export * from './drivers' ;
3
+ export * from './errors' ;
3
4
export * from './interfaces' ;
4
5
export * from './utils' ;
You can’t perform that action at this time.
0 commit comments