Skip to content

Instantly share code, notes, and snippets.

@schickling
Created December 23, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schickling/7105a55cb5bcb9fd479d193d4d0ab605 to your computer and use it in GitHub Desktop.
Save schickling/7105a55cb5bcb9fd479d193d4d0ab605 to your computer and use it in GitHub Desktop.
Runs multiple GraphQL mutations concurrently with a maximum number of parallel promises
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