Mutex helper library for Graphcool
npm install @agartha/graphcool-mutexacquire method will wait for the lock to be released by the currently active operation. This ensures all operations are executed sequentially.
graphql
type Mutex implements Node {
id: ID! @isUnique
name: String! @isUnique
}
`
Usage
Import the library into your Graphcool function.
`js
const { withMutex } = require('@agartha/graphcool-mutex')
`
Wrap your graphcool-lib initialization with withMutex
`js
const graphcool = await withMutex(fromEvent(event))
`
Optionally, you can specify your project region manually, to avoid the async call:
`js
const graphcool = withMutex(fromEvent(event), 'EU_WEST_1')
`
Use the following syntax to acquire a Mutex lock:
`js
await graphcool.mutex.acquire('__MUTEX_NAME__')
`
Use the following syntax to release the lock:
`js
graphcool.mutex.release()
``