Created
December 23, 2016 17:54
-
-
Save schickling/7105a55cb5bcb9fd479d193d4d0ab605 to your computer and use it in GitHub Desktop.
Runs multiple GraphQL mutations concurrently with a maximum number of parallel promises
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
import * as Bluebird from 'bluebird' | |
const myMutations = [ | |
'mutation1: createItem(title: "Node 1") { id }', | |
'mutation2: createItem(title: "Node 2") { id }', | |
// ... | |
] | |
const transport = new Transport('my-graphcool-api') | |
const crm = new Lokka({transport}) | |
async function run() { | |
await Bluebird.map(myMutations, m => api.mutate(m), {concurrency: 4}) // runs max 4 promises at the same time | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment