{"_id":"@agartha/graphcool-mutex","_rev":"7-484ea6927b1c76050a0b2cafc3ab34c4","name":"@agartha/graphcool-mutex","description":"Mutex helper library for Graphcool","dist-tags":{"latest":"0.2.3"},"versions":{"0.1.0":{"name":"@agartha/graphcool-mutex","version":"0.1.0","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d"},"main":"./dist/index.js","types":"./dist/index.d.ts","files":["dist","package.json","README.md"],"dependencies":{"@types/node":"^7.0.14","graphcool-lib":"^0.0.3","graphql-request":"^1.2.0","source-map-support":"^0.4.15","ws":"^3.2.0"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"0b9f293592b983affdce61695c8e58fc31a2c9c1","description":"Mutex helper library for Graphcool","_id":"@agartha/graphcool-mutex@0.1.0","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"integrity":"sha512-R3UUPSL014W6DIcS8PLJMtW3emweOaAkxX/fV7Y+ftZ/8va7CIWSYOlxOu52NASGuoCs+SBbeM6G6az7htmntQ==","shasum":"be5b19e87757979d10bad8f3227d77c522398b4d","tarball":"https://registry.npmjs.org/@agartha/graphcool-mutex/-/graphcool-mutex-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWlxlGQvbBvIBFlt5mK5+a0tTRFaoYMmtupxJUfwXjggIgEm0+J9eO/RK3mj9JAJtv2RCfj1wzu0hu/ATMubw219Y="}]},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphcool-mutex-0.1.0.tgz_1507263706683_0.03067602659575641"}},"0.1.1":{"name":"@agartha/graphcool-mutex","version":"0.1.1","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d"},"main":"./dist/index.js","types":"./dist/index.d.ts","files":["dist","package.json","README.md"],"dependencies":{"@types/node":"^7.0.14","graphcool-lib":"^0.0.3","graphql-request":"^1.2.0","source-map-support":"^0.4.15","ws":"^3.2.0"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"0b9f293592b983affdce61695c8e58fc31a2c9c1","description":"Mutex helper library for Graphcool","_id":"@agartha/graphcool-mutex@0.1.1","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"integrity":"sha512-0Il/DCRrh2LnUsO3NsZedSiGf06uNBNqHeSCIetpfTL8jJ0B3DWrKu3fb52xQBJKBZL+P/Poi5gRyO8Du41tmA==","shasum":"14ef0c8b402415a965060f15f9158c9f00a706fb","tarball":"https://registry.npmjs.org/@agartha/graphcool-mutex/-/graphcool-mutex-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsgUUHnyAn/jNlxJ2QyozQTh856D+cQVcMp2KZ5CW+NgIhANoKbSkf1cwETEzWIRu+zNuQourEaXXEtUhL4gAI57A1"}]},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphcool-mutex-0.1.1.tgz_1507264979258_0.5243836881127208"}},"0.1.2":{"name":"@agartha/graphcool-mutex","version":"0.1.2","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d"},"main":"./dist/index.js","types":"./dist/index.d.ts","license":"GPL-3.0","author":{"name":"Agartha Solutions","email":"info@agarthasolutions.com"},"contributors":"Kim Brandwijk (https://github.com/kbrandwijk)","repository":{"type":"git","url":"git+https://github.com/AgarthaSolutions/graphcool-mutex.git"},"bugs":{"url":"https://github.com/AgarthaSolutions/graphcool-mutex/issues"},"files":["dist","package.json","README.md"],"dependencies":{"@types/node":"^7.0.14","graphcool-lib":"^0.0.3","graphql-request":"^1.2.0","source-map-support":"^0.4.15","ws":"^3.2.0"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"4426670e774a1e398a5d32ac64c001cc5ddfabc9","description":"Mutex helper library for Graphcool","homepage":"https://github.com/AgarthaSolutions/graphcool-mutex#readme","_id":"@agartha/graphcool-mutex@0.1.2","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"integrity":"sha512-xBCzSY3xv7uPLn2YrLsvqw7U/8syaFrKTk4Psu6Mn+M2y3IN1ND+teVid55lR2vgwjga9qakfhpzIHvNhInLWA==","shasum":"ec2036cb8db5a8983d1ddb4505105ba04b961a57","tarball":"https://registry.npmjs.org/@agartha/graphcool-mutex/-/graphcool-mutex-0.1.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHoG8T+4zEbcNdPQzI4yggucaBC8csd3X7kLAgqPEVAYAiEA+loiqdI/UDHFUIM324+naeEHKCKccEpzM9uVUXpR+kA="}]},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphcool-mutex-0.1.2.tgz_1507265873435_0.7191644830163568"}},"0.1.3":{"name":"@agartha/graphcool-mutex","version":"0.1.3","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d"},"main":"./dist/index.js","types":"./dist/index.d.ts","license":"GPL-3.0","author":{"name":"Agartha Solutions","email":"info@agarthasolutions.com"},"contributors":"Kim Brandwijk (https://github.com/kbrandwijk)","repository":{"type":"git","url":"git+https://github.com/AgarthaSolutions/graphcool-mutex.git"},"bugs":{"url":"https://github.com/AgarthaSolutions/graphcool-mutex/issues"},"files":["dist","package.json","README.md"],"dependencies":{"@types/node":"^7.0.14","graphql-request":"^1.2.0","source-map-support":"^0.4.15","ws":"^3.2.0"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"fa1078b01e69f31982f6eb4f89acb79b85fdbdcd","description":"Mutex helper library for Graphcool","homepage":"https://github.com/AgarthaSolutions/graphcool-mutex#readme","_id":"@agartha/graphcool-mutex@0.1.3","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"integrity":"sha512-U4YH65P4VMGvL3hnQSHZIjhgn1VDcwf7fpfXA8cdK0134P8wMHZ+sVivXqevOe4pWmFQ7U5unFmtrRpiWP97GA==","shasum":"edd723fbeedf14f6f260a14d077dc6e2c1f2e19f","tarball":"https://registry.npmjs.org/@agartha/graphcool-mutex/-/graphcool-mutex-0.1.3.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDBqtC2YsbVgkaA7p9ewymdnr70clsK1Uf1CU5VRNAOnAiEAzl7rESeVhy6Q1KCzk7d+/LubmZlGllB9KZRf2on/3LY="}]},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphcool-mutex-0.1.3.tgz_1507266296827_0.03843686473555863"}},"0.2.0":{"name":"@agartha/graphcool-mutex","version":"0.2.0","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d"},"main":"./dist/index.js","types":"./dist/index.d.ts","license":"GPL-3.0","author":{"name":"Agartha Solutions","email":"info@agarthasolutions.com"},"contributors":"Kim Brandwijk (https://github.com/kbrandwijk)","repository":{"type":"git","url":"git+https://github.com/AgarthaSolutions/graphcool-mutex.git"},"bugs":{"url":"https://github.com/AgarthaSolutions/graphcool-mutex/issues"},"files":["dist","package.json","README.md"],"dependencies":{"@types/node":"^7.0.14","graphcool-lib":"^0.0.3","ws":"^3.2.0"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"1361209ba4c52d8ce7301c56fcc913b5cd49136f","description":"Mutex helper library for Graphcool","homepage":"https://github.com/AgarthaSolutions/graphcool-mutex#readme","_id":"@agartha/graphcool-mutex@0.2.0","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"integrity":"sha512-OlSQfz0shZGF5r/EAURfExG46jxNcfou9jefruFJtv4fcqSWWviyHZM0nYZHzrezjMc3GqCfJzXn/aWUSSt0IQ==","shasum":"44be280d881bc00471564e9d59436ccccde9f27a","tarball":"https://registry.npmjs.org/@agartha/graphcool-mutex/-/graphcool-mutex-0.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICD6LRBX2YxQPheMRjUk0Jg0TgnsRnOG0GMu1q1Pr6crAiBEnLumUMLuPq3anENN+5PuBJR4XSY1QOhJ9NCdsxEBtQ=="}]},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphcool-mutex-0.2.0.tgz_1507292935462_0.9904157426208258"}},"0.2.1":{"name":"@agartha/graphcool-mutex","version":"0.2.1","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d"},"main":"./dist/index.js","types":"./dist/index.d.ts","license":"GPL-3.0","author":{"name":"Agartha Solutions","email":"info@agarthasolutions.com"},"contributors":"Kim Brandwijk (https://github.com/kbrandwijk)","repository":{"type":"git","url":"git+https://github.com/AgarthaSolutions/graphcool-mutex.git"},"bugs":{"url":"https://github.com/AgarthaSolutions/graphcool-mutex/issues"},"files":["dist","package.json","README.md"],"dependencies":{"@types/node":"^7.0.14","graphcool-lib":"^0.0.3","ws":"^3.2.0"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"a5ce965e243e775bd59eb23d4651b223585eb2d5","description":"Mutex helper library for Graphcool","homepage":"https://github.com/AgarthaSolutions/graphcool-mutex#readme","_id":"@agartha/graphcool-mutex@0.2.1","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"integrity":"sha512-U94G/FAhXSWJTV0wWgT6zUNGziVNRKMxjsFU0riTBTDjDNtQ+roKFh72gxQkRzhnPj5Jm8KdKvMaESZkH5jfCg==","shasum":"a7c2921b119c509d767c4405c92d86f3563a9af6","tarball":"https://registry.npmjs.org/@agartha/graphcool-mutex/-/graphcool-mutex-0.2.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDnDq/iWKKVL1op67oitmVatq8JUTknQbyvyJNhoBkCnQIgVQkjsgFRJHWM5KZ4Fhr+qUNo2NF7XCcGNwn7TDyw++w="}]},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphcool-mutex-0.2.1.tgz_1507303125935_0.053469324950128794"}},"0.2.3":{"name":"@agartha/graphcool-mutex","version":"0.2.3","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d"},"main":"./dist/index.js","types":"./dist/index.d.ts","license":"GPL-3.0","author":{"name":"Agartha Solutions","email":"info@agarthasolutions.com"},"contributors":"Kim Brandwijk (https://github.com/kbrandwijk)","repository":{"type":"git","url":"git+https://github.com/AgarthaSolutions/graphcool-mutex.git"},"bugs":{"url":"https://github.com/AgarthaSolutions/graphcool-mutex/issues"},"files":["dist","package.json","README.md"],"dependencies":{"@types/node":"^7.0.14","graphcool-lib":"^0.0.3","ws":"^3.2.0"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"92ffdcbb1e987dcbbd9b99d0f0f571089a221a38","description":"Mutex helper library for Graphcool","homepage":"https://github.com/AgarthaSolutions/graphcool-mutex#readme","_id":"@agartha/graphcool-mutex@0.2.3","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"integrity":"sha512-lfGjmHRtVovB+D5TauHXyN0gt4QrflWnpW/prXGM/LVMFkH+7e1LyJvU3dkOXgGmniY04Xf0mfawo6sDP5F33g==","shasum":"860d1a5cce6ddf41fa89318243b073e80506896e","tarball":"https://registry.npmjs.org/@agartha/graphcool-mutex/-/graphcool-mutex-0.2.3.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDBoVZg9HmTqgZxSrsoBUyjY8VSooFJ07wLRg6gUaycVQIgG7AnDgjj+wVIabxcVQVCfbyeEb/yzF6uMpJJYhfSyF4="}]},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphcool-mutex-0.2.3.tgz_1507314775844_0.7189280588645488"}}},"readme":"# graphcool-mutex\r\n\r\nMutex helper library for Graphcool\r\n\r\n## Background\r\n\r\nIf you execute multiple GraphQL mutations, they are processed by the server in parallel.\r\nSometimes however, you need to perform an operation on these mutations that needs to happen sequentially.\r\n\r\nFor example, you want to update an auto-increment field in a pipeline hook, or you want to update a totals field on a parent node.\r\n\r\nIn these cases, you need a mechanism to make sure these operations are executed sequentially. This library implements the Mutex pattern to achieve this.\r\n\r\n![Mutex pattern](./docs/mutexdiagram.jpg)\r\n\r\nEach of the parallel operations (threads) requests a Mutex lock. When the lock does not exist yet, it is acquired immediately. If a lock already exists, the `acquire` method will wait for the lock to be released by the currently active operation. This ensures all operations are executed sequentially.\r\n\r\n> The Mutex is **not** a database lock. It does **not** prevent any mutations against your data. It only halts execution of the operation that tries to acquire a lock.\r\n\r\n## Installation\r\n\r\nUsing this library requires a Type on your Graphcool project with the following schema:\r\n\r\n```graphql\r\ntype Mutex implements Node {\r\n  id: ID! @isUnique\r\n  name: String! @isUnique\r\n}\r\n```\r\n\r\n## Usage\r\n\r\nImport the library into your Graphcool function.\r\n```js\r\nconst { withMutex } = require('@agartha/graphcool-mutex')\r\n```\r\n\r\nWrap your `graphcool-lib` initialization with `withMutex`\r\n```js\r\nconst graphcool = await withMutex(fromEvent(event))\r\n```\r\n\r\nOptionally, you can specify your project region manually, to avoid the async call:\r\n```js\r\nconst graphcool = withMutex(fromEvent(event), 'EU_WEST_1')\r\n```\r\n\r\nUse the following syntax to acquire a Mutex lock:\r\n```js\r\nawait graphcool.mutex.acquire('__MUTEX_NAME__')\r\n```\r\n\r\nUse the following syntax to release the lock:\r\n```js\r\ngraphcool.mutex.release()\r\n```\r\n","maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"time":{"modified":"2022-04-04T11:53:55.725Z","created":"2017-10-06T04:21:47.634Z","0.1.0":"2017-10-06T04:21:47.634Z","0.1.1":"2017-10-06T04:43:00.146Z","0.1.2":"2017-10-06T04:57:54.348Z","0.1.3":"2017-10-06T05:04:57.763Z","0.2.0":"2017-10-06T12:28:56.690Z","0.2.1":"2017-10-06T15:18:46.947Z","0.2.3":"2017-10-06T18:32:56.892Z"},"readmeFilename":"README.md","homepage":"https://github.com/AgarthaSolutions/graphcool-mutex#readme","repository":{"type":"git","url":"git+https://github.com/AgarthaSolutions/graphcool-mutex.git"},"contributors":"Kim Brandwijk (https://github.com/kbrandwijk)","author":{"name":"Agartha Solutions","email":"info@agarthasolutions.com"},"bugs":{"url":"https://github.com/AgarthaSolutions/graphcool-mutex/issues"},"license":"GPL-3.0"}