Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BREAKING] Resolve cached values after batch dispatch
- Loading branch information
Showing
4 changed files
with
176 additions
and
44 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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2019-present, GraphQL Foundation | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
const DataLoader = require('..'); | ||
|
||
describe('Unhandled rejections', () => { | ||
it('Not catching a primed error is an unhandled rejection', async () => { | ||
let hadUnhandledRejection = false; | ||
// Override Jest's unhandled detection | ||
global.jasmine.process.removeAllListeners('unhandledRejection'); | ||
global.jasmine.process.on('unhandledRejection', () => { | ||
hadUnhandledRejection = true; | ||
}); | ||
|
||
const identityLoader = new DataLoader<number, number>(async keys => keys); | ||
|
||
identityLoader.prime(1, new Error('Error: 1')); | ||
|
||
// Ignore result. | ||
identityLoader.load(1); | ||
|
||
await new Promise(resolve => setTimeout(resolve, 10)); | ||
expect(hadUnhandledRejection).toBe(true); | ||
}); | ||
}); |
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