Release notes
*Sourced from [dataloader's releases](https://github.com/graphql/dataloader/releases).*
> ## v2.0.0
> This is the first release since becoming part of the GraphQL Foundation and the most significant since the initial release over four years ago. Read more about the history of the project and this release in the [blog post](https://medium.com/@leeb/dataloader-v2-0-925b4dccf8d6).
>
> **Breaking:**
>
> * [#216](https://github-redirect.dependabot.com/graphql/dataloader/issues/216): `.loadMany()` now returns an array which may contain `Error` if one of the requested keys failed.
> > Previously `.loadMany()` was exactly the same as calling `Promise.all()` on multiple `.load()` calls. While syntactically a minor convenience, this wasn't particularly useful over what could be done with `Promise.all` directly and if one key failed, it meant the entire call to `.loadMany()` would fail. As of this version, `.loadMany()` can now return a mix of values and `Error` instances in the case that some keys failed, but the Promise it returns will never be rejected. This is similar to the behavior of the new [Promise.allSettled](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) method in the upcoming version of JavaScript.
> >
> > This will break any code which relied on `.loadMany()`. To support this change, either ensure the each item in the result of `.loadMany()` are checked against `instanceof Error` or replace calls like `loader.loadMany([k1, k2])` with `Promise.all([loader.load(k1), loader.load(k2))`.
> * [#220](https://github-redirect.dependabot.com/graphql/dataloader/issues/220): The timing of calls to `batchLoadFn` when `{ batch: false }` has changed to the end of the run-loop tick.
> > Previously when batching was disabled the `batchLoadFn` would be called immediately when `.load()` is called. This differed from the `batchLoadFn` being called at the end of the tick of the run-loop for when batching was enabled. This timing difference could lead to subtle race conditions for code which dynamically toggled batching on or off. As a simplification, the `batchLoadFn` is now always called at the end of the run-loop tick regardless of whether batching is disabled.
> >
> > Hopefully this will not break your code. It could cause issues for any code which relied on this synchronous call to `batchLoadFn` for loaders where batching was disabled.
> * [#222](https://github-redirect.dependabot.com/graphql/dataloader/issues/222): Promises for cached values now wait to resolve until the rest of the batch resolves.
> > Previously when `.load()` encountered a cached value it would return an already resolved (or rejected) Promise. However when additional dependent loads happened after these, the difference in time between the cache hit value resolving and the cache miss value resolving would result in additional unnecessary network requests. As of this version when `.load()` encounters a cached value it returns a Promise which waits to resolve until the call to `batchLoadFn` also resolves. This should result in better whole-program performance and is the most significant conceptual change and improvement. This is actually not a new innovation but a correction to match the original behavior of Facebook's "Loader" from 2010 this library is inspired by.
> >
> > This changes the timing of when Promises are resolved and thus could introduce subtle behavioral change in your code, especially if your code is prone to race conditions. Please test carefully.
> >
> > This also means each return of `.load()` is a new Promise instance. Where prior versions returned the same Promise instance for cached results, this version does not. This may break code which uses the returned Promise as a memoization key or in some other way assumed reference equality.
> * [#226](https://github-redirect.dependabot.com/graphql/dataloader/issues/226): The names of private class variables have changed
> > This really shouldn't break your code because you definitely don't reach into class private variables, right? I just figured it would be something you'd like to know, you know... just in case.
>
> **New:**
>
> * [#176](https://github-redirect.dependabot.com/graphql/dataloader/issues/176) [#209](https://github-redirect.dependabot.com/graphql/dataloader/issues/209): MIT licensed (no longer BSD+Patents) and copyrights moved from Facebook to the GraphQL Foundation
> * [#182](https://github-redirect.dependabot.com/graphql/dataloader/issues/182): The DataLoader instance is now available as `this` in `batchLoadFn`
> * [#228](https://github-redirect.dependabot.com/graphql/dataloader/issues/228): Support for custom batch scheduling functions
> > The dirty secret of DataLoader is that most of it is quite boring. The interesting bit is the batch scheduling function which takes advantage of Node.js's unique run-loop scheduler to acheive automatic batching without any additional latency. However since its release, ports to other languages have found this bit to be not be easily replicated and have either replaced it with something conceptually simpler (like manual dispatch) or with a scheduler custom fit to a GraphQL execution engine. These are interesting innovations which deserve ground for experimentation in this original library as well.
> >
> > Via `batchScheduleFn`, you can now provide a custom batch scheduling function and experiment with manual dispatch, added latency dispatch, or any other behavior which might work best for your application.
>
> **Types:**
>
> * [#145](https://github-redirect.dependabot.com/graphql/dataloader/issues/145): Improved TypeScript/Flow types for custom `cacheKeyFn` and `cacheMap`
> * [#146](https://github-redirect.dependabot.com/graphql/dataloader/issues/146): TypeScript types allow `batchLoadFn` to return a `PromiseLike`, supporting use of bluebird
> * [#214](https://github-redirect.dependabot.com/graphql/dataloader/issues/214) [#219](https://github-redirect.dependabot.com/graphql/dataloader/issues/219): TypeScript/Flow types allow `batchLoadFn` to return `ArrayLike`, supporting returning read-only arrays
> * [#168](https://github-redirect.dependabot.com/graphql/dataloader/issues/168): Flow types now use strict mode, allowing safe import into other strict mode code
> * [#217](https://github-redirect.dependabot.com/graphql/dataloader/issues/217): Fixed an issue where TypeScript/Flow would incorrectly report an error when providing an `Error` to `.prime()`
>
> **Fixes:**
>
> * [#215](https://github-redirect.dependabot.com/graphql/dataloader/issues/215): Fixed an issue where a cache could still consume memory, even when caching was disabled
> * [#223](https://github-redirect.dependabot.com/graphql/dataloader/issues/223): Fixed an issue where providing an `Error` to `.prime()` could incorrectly cause an unhandled promise rejection warning
>
> **Documentation:**
>
> * Added references to a ton more ports of DataLoader into other languages (keep 'em coming!)
> * [#213](https://github-redirect.dependabot.com/graphql/dataloader/issues/213): All examples have been updated to latest JavaScript (preferring async/await over Promise chaining)
> * Improved documentation for custom `cacheMap` along with an LRU example.
> * Improved documentation for using higher-order functions on `batchLoadFn`.
> ... (truncated)
Commits
- [`0c05d28`](https://github.com/graphql/dataloader/commit/0c05d28046af19704b67892ef30817b93225d40f) 2.0.0
- [`6592183`](https://github.com/graphql/dataloader/commit/6592183a83025c6cbe9b040ea57faf7a2b81bb50) Support custom schedulers ([#228](https://github-redirect.dependabot.com/graphql/dataloader/issues/228))
- [`3b2192c`](https://github.com/graphql/dataloader/commit/3b2192cfc9e602a416cd87f826d70a9a875e0f43) Add disclaimer for video walkthrough
- [`01c829d`](https://github.com/graphql/dataloader/commit/01c829d4deeeab2c292cc31f49cb9d8124137f97) Resolve all options during construction ([#226](https://github-redirect.dependabot.com/graphql/dataloader/issues/226))
- [`cde0cd8`](https://github.com/graphql/dataloader/commit/cde0cd87243353c35070c95b78743044437f9063) Update issue templates ([#227](https://github-redirect.dependabot.com/graphql/dataloader/issues/227))
- [`06c403b`](https://github.com/graphql/dataloader/commit/06c403bd72abef401dd7619c8ae992f03ed6b7d3) [BREAKING] Resolve cached values after batch dispatch ([#222](https://github-redirect.dependabot.com/graphql/dataloader/issues/222))
- [`b5d7bf5`](https://github.com/graphql/dataloader/commit/b5d7bf57721824e8404347e5407f0fb06198b79a) Refactor batching logic ([#220](https://github-redirect.dependabot.com/graphql/dataloader/issues/220))
- [`a3dd591`](https://github.com/graphql/dataloader/commit/a3dd591a2ec6a9cb4bef9ea7a6c3265434ef94dd) [BREAKING] loadMany() returns individual Error instead of rejecting promise. ...
- [`2f7af56`](https://github.com/graphql/dataloader/commit/2f7af56456eb9b3252efbe70eaa4539bb4b96e93) Add example in documentation for converting object results to Array results.
- [`923a75f`](https://github.com/graphql/dataloader/commit/923a75fd560887b83928ad1379bad77676fad27b) Add example for freezing results with a HOF
- Additional commits viewable in [compare view](https://github.com/graphql/dataloader/compare/v1.4.0...v2.0.0)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme
Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)
Bumps dataloader from 1.4.0 to 2.0.0.
Release notes
*Sourced from [dataloader's releases](https://github.com/graphql/dataloader/releases).* > ## v2.0.0 > This is the first release since becoming part of the GraphQL Foundation and the most significant since the initial release over four years ago. Read more about the history of the project and this release in the [blog post](https://medium.com/@leeb/dataloader-v2-0-925b4dccf8d6). > > **Breaking:** > > * [#216](https://github-redirect.dependabot.com/graphql/dataloader/issues/216): `.loadMany()` now returns an array which may contain `Error` if one of the requested keys failed. > > Previously `.loadMany()` was exactly the same as calling `Promise.all()` on multiple `.load()` calls. While syntactically a minor convenience, this wasn't particularly useful over what could be done with `Promise.all` directly and if one key failed, it meant the entire call to `.loadMany()` would fail. As of this version, `.loadMany()` can now return a mix of values and `Error` instances in the case that some keys failed, but the Promise it returns will never be rejected. This is similar to the behavior of the new [Promise.allSettled](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) method in the upcoming version of JavaScript. > > > > This will break any code which relied on `.loadMany()`. To support this change, either ensure the each item in the result of `.loadMany()` are checked against `instanceof Error` or replace calls like `loader.loadMany([k1, k2])` with `Promise.all([loader.load(k1), loader.load(k2))`. > * [#220](https://github-redirect.dependabot.com/graphql/dataloader/issues/220): The timing of calls to `batchLoadFn` when `{ batch: false }` has changed to the end of the run-loop tick. > > Previously when batching was disabled the `batchLoadFn` would be called immediately when `.load()` is called. This differed from the `batchLoadFn` being called at the end of the tick of the run-loop for when batching was enabled. This timing difference could lead to subtle race conditions for code which dynamically toggled batching on or off. As a simplification, the `batchLoadFn` is now always called at the end of the run-loop tick regardless of whether batching is disabled. > > > > Hopefully this will not break your code. It could cause issues for any code which relied on this synchronous call to `batchLoadFn` for loaders where batching was disabled. > * [#222](https://github-redirect.dependabot.com/graphql/dataloader/issues/222): Promises for cached values now wait to resolve until the rest of the batch resolves. > > Previously when `.load()` encountered a cached value it would return an already resolved (or rejected) Promise. However when additional dependent loads happened after these, the difference in time between the cache hit value resolving and the cache miss value resolving would result in additional unnecessary network requests. As of this version when `.load()` encounters a cached value it returns a Promise which waits to resolve until the call to `batchLoadFn` also resolves. This should result in better whole-program performance and is the most significant conceptual change and improvement. This is actually not a new innovation but a correction to match the original behavior of Facebook's "Loader" from 2010 this library is inspired by. > > > > This changes the timing of when Promises are resolved and thus could introduce subtle behavioral change in your code, especially if your code is prone to race conditions. Please test carefully. > > > > This also means each return of `.load()` is a new Promise instance. Where prior versions returned the same Promise instance for cached results, this version does not. This may break code which uses the returned Promise as a memoization key or in some other way assumed reference equality. > * [#226](https://github-redirect.dependabot.com/graphql/dataloader/issues/226): The names of private class variables have changed > > This really shouldn't break your code because you definitely don't reach into class private variables, right? I just figured it would be something you'd like to know, you know... just in case. > > **New:** > > * [#176](https://github-redirect.dependabot.com/graphql/dataloader/issues/176) [#209](https://github-redirect.dependabot.com/graphql/dataloader/issues/209): MIT licensed (no longer BSD+Patents) and copyrights moved from Facebook to the GraphQL Foundation > * [#182](https://github-redirect.dependabot.com/graphql/dataloader/issues/182): The DataLoader instance is now available as `this` in `batchLoadFn` > * [#228](https://github-redirect.dependabot.com/graphql/dataloader/issues/228): Support for custom batch scheduling functions > > The dirty secret of DataLoader is that most of it is quite boring. The interesting bit is the batch scheduling function which takes advantage of Node.js's unique run-loop scheduler to acheive automatic batching without any additional latency. However since its release, ports to other languages have found this bit to be not be easily replicated and have either replaced it with something conceptually simpler (like manual dispatch) or with a scheduler custom fit to a GraphQL execution engine. These are interesting innovations which deserve ground for experimentation in this original library as well. > > > > Via `batchScheduleFn`, you can now provide a custom batch scheduling function and experiment with manual dispatch, added latency dispatch, or any other behavior which might work best for your application. > > **Types:** > > * [#145](https://github-redirect.dependabot.com/graphql/dataloader/issues/145): Improved TypeScript/Flow types for custom `cacheKeyFn` and `cacheMap` > * [#146](https://github-redirect.dependabot.com/graphql/dataloader/issues/146): TypeScript types allow `batchLoadFn` to return a `PromiseLike`, supporting use of bluebird > * [#214](https://github-redirect.dependabot.com/graphql/dataloader/issues/214) [#219](https://github-redirect.dependabot.com/graphql/dataloader/issues/219): TypeScript/Flow types allow `batchLoadFn` to return `ArrayLike`, supporting returning read-only arrays > * [#168](https://github-redirect.dependabot.com/graphql/dataloader/issues/168): Flow types now use strict mode, allowing safe import into other strict mode code > * [#217](https://github-redirect.dependabot.com/graphql/dataloader/issues/217): Fixed an issue where TypeScript/Flow would incorrectly report an error when providing an `Error` to `.prime()` > > **Fixes:** > > * [#215](https://github-redirect.dependabot.com/graphql/dataloader/issues/215): Fixed an issue where a cache could still consume memory, even when caching was disabled > * [#223](https://github-redirect.dependabot.com/graphql/dataloader/issues/223): Fixed an issue where providing an `Error` to `.prime()` could incorrectly cause an unhandled promise rejection warning > > **Documentation:** > > * Added references to a ton more ports of DataLoader into other languages (keep 'em coming!) > * [#213](https://github-redirect.dependabot.com/graphql/dataloader/issues/213): All examples have been updated to latest JavaScript (preferring async/await over Promise chaining) > * Improved documentation for custom `cacheMap` along with an LRU example. > * Improved documentation for using higher-order functions on `batchLoadFn`. > ... (truncated)Commits
- [`0c05d28`](https://github.com/graphql/dataloader/commit/0c05d28046af19704b67892ef30817b93225d40f) 2.0.0 - [`6592183`](https://github.com/graphql/dataloader/commit/6592183a83025c6cbe9b040ea57faf7a2b81bb50) Support custom schedulers ([#228](https://github-redirect.dependabot.com/graphql/dataloader/issues/228)) - [`3b2192c`](https://github.com/graphql/dataloader/commit/3b2192cfc9e602a416cd87f826d70a9a875e0f43) Add disclaimer for video walkthrough - [`01c829d`](https://github.com/graphql/dataloader/commit/01c829d4deeeab2c292cc31f49cb9d8124137f97) Resolve all options during construction ([#226](https://github-redirect.dependabot.com/graphql/dataloader/issues/226)) - [`cde0cd8`](https://github.com/graphql/dataloader/commit/cde0cd87243353c35070c95b78743044437f9063) Update issue templates ([#227](https://github-redirect.dependabot.com/graphql/dataloader/issues/227)) - [`06c403b`](https://github.com/graphql/dataloader/commit/06c403bd72abef401dd7619c8ae992f03ed6b7d3) [BREAKING] Resolve cached values after batch dispatch ([#222](https://github-redirect.dependabot.com/graphql/dataloader/issues/222)) - [`b5d7bf5`](https://github.com/graphql/dataloader/commit/b5d7bf57721824e8404347e5407f0fb06198b79a) Refactor batching logic ([#220](https://github-redirect.dependabot.com/graphql/dataloader/issues/220)) - [`a3dd591`](https://github.com/graphql/dataloader/commit/a3dd591a2ec6a9cb4bef9ea7a6c3265434ef94dd) [BREAKING] loadMany() returns individual Error instead of rejecting promise. ... - [`2f7af56`](https://github.com/graphql/dataloader/commit/2f7af56456eb9b3252efbe70eaa4539bb4b96e93) Add example in documentation for converting object results to Array results. - [`923a75f`](https://github.com/graphql/dataloader/commit/923a75fd560887b83928ad1379bad77676fad27b) Add example for freezing results with a HOF - Additional commits viewable in [compare view](https://github.com/graphql/dataloader/compare/v1.4.0...v2.0.0)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language - `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com): - Update frequency (including time of day and day of week) - Pull request limits (per update run and/or open at any time) - Out-of-range updates (receive only lockfile updates, if desired) - Security updates (receive only security updates, if desired)