Skip to content

Commit 74f00a0

Browse files
committed
Rm undocumented req.reject API usage
1 parent aff200e commit 74f00a0

File tree

3 files changed

+3
-34
lines changed

3 files changed

+3
-34
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
ORDER_EXCEEDS_STOCK=The order of {0} books exceeds the stock by {1}
2-
ORDER_EXCEEDS_STOCK_NO_ARGS=The order of books exceeds the stock
1+
ORDER_EXCEEDS_STOCK=The order of {0} books exceeds the stock by {1}

test/resources/error-handling/srv/custom-handler-errors.js

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ module.exports = srv => {
7272

7373
if (id === 1) req.reject(400, message, args)
7474
if (id === 2) req.reject(code, message, args)
75-
req.reject('ORDER_EXCEEDS_STOCK_NO_ARGS')
7675
}
7776
})
7877
}

test/tests/error-handling-dev.test.js

+2-31
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,15 @@ describe('graphql - error handling in development', () => {
347347
message: 'Some Custom Error Message 1',
348348
numericSeverity: 4,
349349
status: 418,
350-
target: 'some_field',
350+
target: 'some_field'
351351
// stack: expect.any(String) // doesn't work with Node 22
352352
},
353353
{
354354
code: 'Some-Custom-Code2',
355355
message: 'Some Custom Error Message 2',
356356
numericSeverity: 4,
357357
status: 500,
358-
target: 'some_field',
358+
target: 'some_field'
359359
// stack: expect.any(String) // doesn't work with Node 22
360360
}
361361
]
@@ -452,34 +452,5 @@ describe('graphql - error handling in development', () => {
452452
expect(response.data).toMatchObject({ errors })
453453
expect(response.data.errors[0].extensions.stacktrace).not.toHaveLength(0) // Stacktrace exists and is not empty
454454
})
455-
456-
test('req.reject with custom code', async () => {
457-
const query = gql`
458-
mutation {
459-
CustomHandlerErrorsService {
460-
Orders {
461-
create(input: { id: 3, quantity: 20, stock: 10 }) {
462-
id
463-
quantity
464-
stock
465-
}
466-
}
467-
}
468-
}
469-
`
470-
const errors = [
471-
{
472-
message: 'The order of books exceeds the stock',
473-
extensions: {
474-
code: '500',
475-
numericSeverity: 4,
476-
stacktrace: expect.any(Array)
477-
}
478-
}
479-
]
480-
const response = await POST('/graphql', { query })
481-
expect(response.data).toMatchObject({ errors })
482-
expect(response.data.errors[0].extensions.stacktrace).not.toHaveLength(0) // Stacktrace exists and is not empty
483-
})
484455
})
485456
})

0 commit comments

Comments
 (0)