Skip to content

Commit

Permalink
Rm undocumented req.reject API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
schwma committed Oct 9, 2024
1 parent aff200e commit 74f00a0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 34 deletions.
3 changes: 1 addition & 2 deletions test/resources/error-handling/i18n/messages_en.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ORDER_EXCEEDS_STOCK=The order of {0} books exceeds the stock by {1}
ORDER_EXCEEDS_STOCK_NO_ARGS=The order of books exceeds the stock
ORDER_EXCEEDS_STOCK=The order of {0} books exceeds the stock by {1}
1 change: 0 additions & 1 deletion test/resources/error-handling/srv/custom-handler-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ module.exports = srv => {

if (id === 1) req.reject(400, message, args)
if (id === 2) req.reject(code, message, args)
req.reject('ORDER_EXCEEDS_STOCK_NO_ARGS')
}
})
}
33 changes: 2 additions & 31 deletions test/tests/error-handling-dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,15 @@ describe('graphql - error handling in development', () => {
message: 'Some Custom Error Message 1',
numericSeverity: 4,
status: 418,
target: 'some_field',
target: 'some_field'
// stack: expect.any(String) // doesn't work with Node 22
},
{
code: 'Some-Custom-Code2',
message: 'Some Custom Error Message 2',
numericSeverity: 4,
status: 500,
target: 'some_field',
target: 'some_field'
// stack: expect.any(String) // doesn't work with Node 22
}
]
Expand Down Expand Up @@ -452,34 +452,5 @@ describe('graphql - error handling in development', () => {
expect(response.data).toMatchObject({ errors })
expect(response.data.errors[0].extensions.stacktrace).not.toHaveLength(0) // Stacktrace exists and is not empty
})

test('req.reject with custom code', async () => {
const query = gql`
mutation {
CustomHandlerErrorsService {
Orders {
create(input: { id: 3, quantity: 20, stock: 10 }) {
id
quantity
stock
}
}
}
}
`
const errors = [
{
message: 'The order of books exceeds the stock',
extensions: {
code: '500',
numericSeverity: 4,
stacktrace: expect.any(Array)
}
}
]
const response = await POST('/graphql', { query })
expect(response.data).toMatchObject({ errors })
expect(response.data.errors[0].extensions.stacktrace).not.toHaveLength(0) // Stacktrace exists and is not empty
})
})
})

0 comments on commit 74f00a0

Please sign in to comment.