yarn add graphql-batching-helpers
or
npm install --save graphql-batching-helpers
- process.env.GRAPHQL_ENDPOINT
- process.env.GRAPHQL_ACCESS_TOKEN
await BatchQueryHelpers.batchDeleteAllModels({
modelName: 'Contact',
first: 100,
concurrency: 4,
})
What happens in order:
- generate generate batch query name:
query getContacts {
contacts: allContacts(first: 100) {
id
}
}
- Request first N
Contact
s - If there are more than 0:
- Generate match query mutations
- Delete first N with concurrency N
generateBatchQuery
- modelName: String ("Contact")
- first: Int (100)
generateBatchDeleteMutation
- modelName: String ("Contact")
- id
generateBatchDeleteMutations
- values
- id: String ("xyz")
- options
- modelName: String ("Contact")
- values
runBatchQuery
- options
- modelName: String ("Contact")
- first: Int (100)
- options
runBatchDelete
- mutations
- options
- concurrency: Int (4)
batchDeleteAllModels
- options
- modelName: String ("Contact")
- first: Int (100)
- concurrency: Int (4)
- options