@@ -15,7 +15,7 @@ declare module 'graphql' {
15
15
}
16
16
}
17
17
18
- export class BaseGraphQLError extends Error implements GraphQLError {
18
+ export class BaseGraphQLError extends GraphQLError {
19
19
public extensions : Record < string , any > ;
20
20
override readonly name ! : string ;
21
21
readonly locations : ReadonlyArray < SourceLocation > | undefined ;
@@ -84,23 +84,23 @@ export class SyntaxError extends BaseGraphQLError {
84
84
85
85
export class ValidationError extends BaseGraphQLError {
86
86
constructor ( message : string ) {
87
- super ( message , 'GRAPHQL_VALIDATION_FAILED' ) ;
87
+ super ( message , 'GRAPHQL_VALIDATION_FAILED' , { http : { status : 400 } } ) ;
88
88
89
89
Object . defineProperty ( this , 'name' , { value : 'ValidationError' } ) ;
90
90
}
91
91
}
92
92
93
93
export class AuthenticationError extends BaseGraphQLError {
94
94
constructor ( message : string , extensions ?: Record < string , any > ) {
95
- super ( message , 'UNAUTHENTICATED' , extensions ) ;
95
+ super ( message , 'UNAUTHENTICATED' , { ... extensions , http : { status : 401 } } ) ;
96
96
97
97
Object . defineProperty ( this , 'name' , { value : 'AuthenticationError' } ) ;
98
98
}
99
99
}
100
100
101
101
export class ForbiddenError extends BaseGraphQLError {
102
102
constructor ( message : string , extensions ?: Record < string , any > ) {
103
- super ( message , 'FORBIDDEN' , extensions ) ;
103
+ super ( message , 'FORBIDDEN' , { ... extensions , http : { status : 403 } } ) ;
104
104
105
105
Object . defineProperty ( this , 'name' , { value : 'ForbiddenError' } ) ;
106
106
}
@@ -136,31 +136,34 @@ export class UserInputError extends BaseGraphQLError {
136
136
137
137
export class NotFoundError extends BaseGraphQLError {
138
138
constructor ( message : string , extensions ?: Record < string , any > ) {
139
- super ( message , 'NOT_FOUND' , extensions ) ;
139
+ super ( message , 'NOT_FOUND' , { ... extensions , http : { status : 404 } } ) ;
140
140
141
141
Object . defineProperty ( this , 'name' , { value : 'NotFoundError' } ) ;
142
142
}
143
143
}
144
144
145
145
export class MethodNotAllowedError extends BaseGraphQLError {
146
146
constructor ( message : string , extensions ?: Record < string , any > ) {
147
- super ( message , 'METHOD_NOT_ALLOWED' , extensions ) ;
147
+ super ( message , 'METHOD_NOT_ALLOWED' , {
148
+ ...extensions ,
149
+ http : { status : 405 } ,
150
+ } ) ;
148
151
149
152
Object . defineProperty ( this , 'name' , { value : 'MethodNotAllowedError' } ) ;
150
153
}
151
154
}
152
155
153
156
export class ConflictError extends BaseGraphQLError {
154
157
constructor ( message : string , extensions ?: Record < string , any > ) {
155
- super ( message , 'CONFLICT' , extensions ) ;
158
+ super ( message , 'CONFLICT' , { ... extensions , http : { status : 409 } } ) ;
156
159
157
160
Object . defineProperty ( this , 'name' , { value : 'ConflictError' } ) ;
158
161
}
159
162
}
160
163
161
164
export class TimeoutError extends BaseGraphQLError {
162
165
constructor ( message : string , extensions ?: Record < string , any > ) {
163
- super ( message , 'TIMEOUT' , extensions ) ;
166
+ super ( message , 'TIMEOUT' , { ... extensions , http : { status : 408 } } ) ;
164
167
165
168
Object . defineProperty ( this , 'name' , { value : 'TimeoutError' } ) ;
166
169
}
0 commit comments