Last active
April 21, 2020 02:12
-
-
Save holyshared/f1368e299582e8f0b2b54d7cbebc7076 to your computer and use it in GitHub Desktop.
DataLoader
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
[*.js] | |
indent_style = space | |
indent_size = 2 |
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
const DataLoader = require('dataloader'); | |
const loader = new DataLoader(async (keys) => { | |
return keys.map(key => ({ key })); | |
}); | |
Promise.all([ | |
loader.load(1), | |
loader.loadMany([1, 2, 3]) | |
]).then((res) => { | |
console.log(res); | |
}); |
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
{ | |
"name": "dataloader-ex", | |
"version": "1.0.0", | |
"main": "index.js", | |
"repository": "git@gist.github.com:f1368e299582e8f0b2b54d7cbebc7076.git", | |
"author": "holyshared <holy.shared.design@gmail.com>", | |
"license": "MIT", | |
"dependencies": { | |
"dataloader": "^2.0.0" | |
} | |
} |
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 IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | |
# yarn lockfile v1 | |
dataloader@^2.0.0: | |
version "2.0.0" | |
resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-2.0.0.tgz#41eaf123db115987e21ca93c005cd7753c55fe6f" | |
integrity sha512-YzhyDAwA4TaQIhM5go+vCLmU0UikghC/t9DTQYZR2M/UvZ1MdOhPezSDZcjj9uqQJOMqjLcpWtyW2iNINdlatQ== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment