{"_id":"graphql-sse","_rev":"1683682","name":"graphql-sse","description":"Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client","dist-tags":{"latest":"1.0.6"},"maintainers":[{"name":"npm:enisdenjo","email":""}],"time":{"modified":"2021-11-25T03:46:04.000Z","created":"2020-11-18T09:59:17.003Z","1.0.6":"2021-11-18T17:00:44.707Z","1.0.5":"2021-11-02T11:49:34.688Z","1.0.4":"2021-09-08T21:45:19.714Z","1.0.3":"2021-08-26T19:16:17.369Z","1.0.2":"2021-08-26T19:10:01.910Z","1.0.1":"2021-08-23T13:37:13.771Z","1.0.0":"2021-08-21T15:01:41.523Z","0.0.0":"2020-11-18T09:59:17.003Z"},"users":{},"author":{"name":"Denis Badurina","email":"badurinadenis@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/enisdenjo/graphql-sse.git"},"versions":{"1.0.6":{"name":"graphql-sse","version":"1.0.6","description":"Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client","keywords":["graphql","client","relay","express","apollo","server","sse","transport","server-sent-events","observables","subscriptions","fastify"],"author":{"name":"Denis Badurina","email":"badurinadenis@gmail.com"},"license":"MIT","homepage":"https://github.com/enisdenjo/graphql-sse#readme","repository":{"type":"git","url":"git+https://github.com/enisdenjo/graphql-sse.git"},"engines":{"node":">=12"},"packageManager":"yarn@3.1.0","main":"lib/index.js","module":"lib/index.mjs","browser":"umd/graphql-sse.js","exports":{".":{"require":"./lib/index.js","import":"./lib/index.mjs","browser":"./umd/graphql-sse.js"},"./package.json":"./package.json"},"types":"lib/index.d.ts","sideEffects":["umd/*"],"publishConfig":{"access":"public"},"scripts":{"gendocs":"typedoc --options typedoc.js src/","lint":"eslint 'src'","type-check":"tsc --noEmit","test":"jest","build:esm":"tsc -b tsconfig.esm.json && node scripts/esm-post-process.js","build:cjs":"tsc -b tsconfig.cjs.json","build:umd":"rollup -c && gzip umd/graphql-sse.min.js -c > umd/graphql-sse.min.js.gz","build":"yarn build:esm && yarn build:cjs && yarn build:umd","release":"semantic-release"},"peerDependencies":{"graphql":">=0.11 <=16"},"devDependencies":{"@babel/core":"^7.16.0","@babel/plugin-proposal-class-properties":"^7.16.0","@babel/plugin-proposal-nullish-coalescing-operator":"^7.16.0","@babel/plugin-proposal-object-rest-spread":"^7.16.0","@babel/plugin-proposal-optional-chaining":"^7.16.0","@babel/preset-env":"^7.16.0","@babel/preset-typescript":"^7.16.0","@rollup/plugin-typescript":"^8.3.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/eventsource":"^1.1.7","@types/express":"^4.17.13","@types/jest":"^26.0.24","@types/node-fetch":"^2.5.12","@typescript-eslint/eslint-plugin":"^5.3.1","@typescript-eslint/parser":"^5.3.1","babel-jest":"^27.3.1","eslint":"^8.2.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0","eventsource":"^1.1.0","express":"^4.17.1","fastify":"^3.23.1","graphql":"^16.0.1","jest":"^27.3.1","node-fetch":"^2.6.6","prettier":"^2.4.1","replacestream":"^4.0.3","rollup":"^2.59.0","rollup-plugin-terser":"^7.0.2","semantic-release":"^18.0.0","tslib":"^2.3.1","typedoc":"^0.22.8","typedoc-plugin-markdown":"^3.11.3","typescript":"^4.4.4"},"gitHead":"9843e5156f8cf1b6d5c5e52dd4969cf26b925c76","bugs":{"url":"https://github.com/enisdenjo/graphql-sse/issues"},"_id":"graphql-sse@1.0.6","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"shasum":"4f98e0a06f2020542ed054399116108491263224","size":53373,"noattachment":false,"key":"/graphql-sse/-/graphql-sse-1.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/graphql-sse/download/graphql-sse-1.0.6.tgz"},"_npmUser":{"name":"enisdenjo","email":"badurinadenis@gmail.com"},"directories":{},"maintainers":[{"name":"npm:enisdenjo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-sse_1.0.6_1637254844516_0.979668620807878"},"_hasShrinkwrap":false,"publish_time":1637254844707,"_cnpm_publish_time":1637254844707},"1.0.5":{"name":"graphql-sse","version":"1.0.5","description":"Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client","keywords":["graphql","client","relay","express","apollo","server","sse","transport","server-sent-events","observables","subscriptions","fastify"],"author":{"name":"Denis Badurina","email":"badurinadenis@gmail.com"},"license":"MIT","homepage":"https://github.com/enisdenjo/graphql-sse#readme","repository":{"type":"git","url":"git+https://github.com/enisdenjo/graphql-sse.git"},"engines":{"node":">=12"},"main":"lib/index.js","module":"lib/index.mjs","browser":"umd/graphql-sse.js","exports":{".":{"require":"./lib/index.js","import":"./lib/index.mjs","browser":"./umd/graphql-sse.js"},"./package.json":"./package.json"},"types":"lib/index.d.ts","sideEffects":["umd/*"],"publishConfig":{"access":"public"},"scripts":{"gendocs":"typedoc --options typedoc.js src/","lint":"eslint 'src'","type-check":"tsc --noEmit","test":"jest","build:esm":"tsc -b tsconfig.esm.json && node scripts/esm-post-process.js","build:cjs":"tsc -b tsconfig.cjs.json","build:umd":"rollup -c && gzip umd/graphql-sse.min.js -c > umd/graphql-sse.min.js.gz","build":"yarn build:esm && yarn build:cjs && yarn build:umd","release":"semantic-release"},"peerDependencies":{"graphql":">=0.11 <=16"},"devDependencies":{"@babel/core":"^7.16.0","@babel/plugin-proposal-class-properties":"^7.16.0","@babel/plugin-proposal-nullish-coalescing-operator":"^7.16.0","@babel/plugin-proposal-object-rest-spread":"^7.16.0","@babel/plugin-proposal-optional-chaining":"^7.16.0","@babel/preset-env":"^7.16.0","@babel/preset-typescript":"^7.16.0","@rollup/plugin-typescript":"^8.3.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/eventsource":"^1.1.7","@types/express":"^4.17.13","@types/jest":"^26.0.24","@types/node-fetch":"^2.5.12","@typescript-eslint/eslint-plugin":"^5.3.0","@typescript-eslint/parser":"^5.3.0","babel-jest":"^27.3.1","eslint":"^8.1.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0","eventsource":"^1.1.0","express":"^4.17.1","fastify":"^3.22.1","graphql":"^16.0.1","jest":"^27.3.1","node-fetch":"^2.6.6","prettier":"^2.4.1","replacestream":"^4.0.3","rollup":"^2.59.0","rollup-plugin-terser":"^7.0.2","semantic-release":"^18.0.0","tslib":"^2.3.1","typedoc":"^0.22.7","typedoc-plugin-markdown":"^3.11.3","typescript":"^4.4.4"},"gitHead":"ac8827c9c29b703478c6df605d7c9f1c46fbc7a7","bugs":{"url":"https://github.com/enisdenjo/graphql-sse/issues"},"_id":"graphql-sse@1.0.5","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"shasum":"9185dc4764cce9296fc90341f9fdac9ed024ff67","size":52438,"noattachment":false,"key":"/graphql-sse/-/graphql-sse-1.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/graphql-sse/download/graphql-sse-1.0.5.tgz"},"_npmUser":{"name":"enisdenjo","email":"badurinadenis@gmail.com"},"directories":{},"maintainers":[{"name":"npm:enisdenjo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-sse_1.0.5_1635853774511_0.6138782777358174"},"_hasShrinkwrap":false,"publish_time":1635853774688,"_cnpm_publish_time":1635853774688},"1.0.4":{"name":"graphql-sse","version":"1.0.4","description":"Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client","keywords":["graphql","client","relay","express","apollo","server","sse","transport","server-sent-events","observables","subscriptions","fastify"],"author":{"name":"Denis Badurina","email":"badurinadenis@gmail.com"},"license":"MIT","homepage":"https://github.com/enisdenjo/graphql-sse#readme","repository":{"type":"git","url":"git+https://github.com/enisdenjo/graphql-sse.git"},"engines":{"node":">=12"},"main":"lib/index.js","module":"lib/index.mjs","browser":"umd/graphql-sse.js","exports":{".":{"require":"./lib/index.js","import":"./lib/index.mjs","browser":"./umd/graphql-sse.js"},"./package.json":"./package.json"},"types":"lib/index.d.ts","sideEffects":["umd/*"],"publishConfig":{"access":"public"},"scripts":{"gendocs":"typedoc --options typedoc.js src/","lint":"eslint 'src'","type-check":"tsc --noEmit","test":"jest","build:esm":"tsc -b tsconfig.esm.json && node scripts/esm-post-process.js","build:cjs":"tsc -b tsconfig.cjs.json","build:umd":"rollup -c && gzip umd/graphql-sse.min.js -c > umd/graphql-sse.min.js.gz","build":"yarn build:esm && yarn build:cjs && yarn build:umd","release":"semantic-release"},"peerDependencies":{"graphql":">=0.11 <=16"},"devDependencies":{"@babel/core":"^7.15.0","@babel/plugin-proposal-class-properties":"^7.14.5","@babel/plugin-proposal-nullish-coalescing-operator":"^7.14.5","@babel/plugin-proposal-object-rest-spread":"^7.14.7","@babel/plugin-proposal-optional-chaining":"^7.14.5","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.15.0","@rollup/plugin-typescript":"^8.2.5","@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","@types/eventsource":"^1.1.6","@types/jest":"^26.0.24","@types/node-fetch":"^2.5.12","@typescript-eslint/eslint-plugin":"^4.29.3","@typescript-eslint/parser":"^4.29.3","babel-jest":"^27.0.6","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^3.4.1","eventsource":"^1.1.0","graphql":"16.0.0-rc.2.experimental-stream-defer.3","jest":"^27.0.6","node-fetch":"^2.6.1","prettier":"^2.3.2","replacestream":"^4.0.3","rollup":"^2.56.3","rollup-plugin-terser":"^7.0.2","semantic-release":"^17.4.7","tslib":"^2.3.1","typedoc":"^0.21.6","typedoc-plugin-markdown":"^3.10.4","typescript":"4.3.5"},"gitHead":"15eba706f761da2b73877aa23d290b73f4f94e4e","bugs":{"url":"https://github.com/enisdenjo/graphql-sse/issues"},"_id":"graphql-sse@1.0.4","_nodeVersion":"16.9.0","_npmVersion":"7.21.1","dist":{"shasum":"051598b0e06c225327aac659f19fcc18bcaa0191","size":52391,"noattachment":false,"key":"/graphql-sse/-/graphql-sse-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/graphql-sse/download/graphql-sse-1.0.4.tgz"},"_npmUser":{"name":"enisdenjo","email":"badurinadenis@gmail.com"},"directories":{},"maintainers":[{"name":"npm:enisdenjo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-sse_1.0.4_1631137519509_0.14239365728175768"},"_hasShrinkwrap":false,"publish_time":1631137519714,"_cnpm_publish_time":1631137519714},"1.0.3":{"name":"graphql-sse","version":"1.0.3","description":"Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client","keywords":["graphql","client","relay","express","apollo","server","sse","transport","server-sent-events","observables","subscriptions","fastify"],"author":{"name":"Denis Badurina","email":"badurinadenis@gmail.com"},"license":"MIT","homepage":"https://github.com/enisdenjo/graphql-sse#readme","repository":{"type":"git","url":"git+https://github.com/enisdenjo/graphql-sse.git"},"engines":{"node":">=12"},"main":"lib/index.js","module":"lib/index.mjs","browser":"umd/graphql-sse.js","exports":{".":{"require":"./lib/index.js","import":"./lib/index.mjs","browser":"./umd/graphql-sse.js"},"./package.json":"./package.json"},"types":"lib/index.d.ts","sideEffects":["umd/*"],"publishConfig":{"access":"public"},"scripts":{"gendocs":"typedoc --options typedoc.js src/","lint":"eslint 'src'","type-check":"tsc --noEmit","test":"jest","build:esm":"tsc -b tsconfig.esm.json && node scripts/esm-post-process.js","build:cjs":"tsc -b tsconfig.cjs.json","build:umd":"rollup -c && gzip umd/graphql-sse.min.js -c > umd/graphql-sse.min.js.gz","build":"yarn build:esm && yarn build:cjs && yarn build:umd","release":"semantic-release"},"peerDependencies":{"graphql":">=0.11 <=16"},"devDependencies":{"@babel/core":"^7.15.0","@babel/plugin-proposal-class-properties":"^7.14.5","@babel/plugin-proposal-nullish-coalescing-operator":"^7.14.5","@babel/plugin-proposal-object-rest-spread":"^7.14.7","@babel/plugin-proposal-optional-chaining":"^7.14.5","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.15.0","@rollup/plugin-typescript":"^8.2.5","@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","@types/eventsource":"^1.1.6","@types/jest":"^26.0.24","@types/node-fetch":"^2.5.12","@typescript-eslint/eslint-plugin":"^4.29.3","@typescript-eslint/parser":"^4.29.3","babel-jest":"^27.0.6","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^3.4.1","eventsource":"^1.1.0","graphql":"^16.0.0-rc.1","jest":"^27.0.6","node-fetch":"^2.6.1","prettier":"^2.3.2","replacestream":"^4.0.3","rollup":"^2.56.3","rollup-plugin-terser":"^7.0.2","semantic-release":"^17.4.7","tslib":"^2.3.1","typedoc":"^0.21.6","typedoc-plugin-markdown":"^3.10.4","typescript":"^4.3.5"},"gitHead":"bd06b37257b9599302829d52359896eb225bb222","bugs":{"url":"https://github.com/enisdenjo/graphql-sse/issues"},"_id":"graphql-sse@1.0.3","_nodeVersion":"16.8.0","_npmVersion":"7.21.0","dist":{"shasum":"122a67e4f59af26bba4d937b7c0bab7ec536144b","size":52171,"noattachment":false,"key":"/graphql-sse/-/graphql-sse-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/graphql-sse/download/graphql-sse-1.0.3.tgz"},"_npmUser":{"name":"enisdenjo","email":"badurinadenis@gmail.com"},"directories":{},"maintainers":[{"name":"npm:enisdenjo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-sse_1.0.3_1630005377195_0.60672047512636"},"_hasShrinkwrap":false,"publish_time":1630005377369,"_cnpm_publish_time":1630005377369},"1.0.2":{"name":"graphql-sse","version":"1.0.2","description":"Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client","keywords":["graphql","client","relay","express","apollo","server","sse","transport","server-sent-events","observables","subscriptions","fastify"],"author":{"name":"Denis Badurina","email":"badurinadenis@gmail.com"},"license":"MIT","homepage":"https://github.com/enisdenjo/graphql-sse#readme","repository":{"type":"git","url":"git+https://github.com/enisdenjo/graphql-sse.git"},"engines":{"node":">=12"},"main":"lib/index.js","module":"lib/index.mjs","browser":"umd/graphql-sse.js","exports":{".":{"require":"./lib/index.js","import":"./lib/index.mjs","browser":"./umd/graphql-sse.js"},"./package.json":"./package.json"},"types":"lib/index.d.ts","sideEffects":["umd/*"],"publishConfig":{"access":"public"},"scripts":{"gendocs":"typedoc --options typedoc.js src/","lint":"eslint 'src'","type-check":"tsc --noEmit","test":"jest","build:esm":"tsc -b tsconfig.esm.json && node scripts/esm-post-process.js","build:cjs":"tsc -b tsconfig.cjs.json","build:umd":"rollup -c && gzip umd/graphql-sse.min.js -c > umd/graphql-sse.min.js.gz","build":"yarn build:esm && yarn build:cjs && yarn build:umd","release":"semantic-release"},"peerDependencies":{"graphql":">=0.11 <=15"},"devDependencies":{"@babel/core":"^7.15.0","@babel/plugin-proposal-class-properties":"^7.14.5","@babel/plugin-proposal-nullish-coalescing-operator":"^7.14.5","@babel/plugin-proposal-object-rest-spread":"^7.14.7","@babel/plugin-proposal-optional-chaining":"^7.14.5","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.15.0","@rollup/plugin-typescript":"^8.2.5","@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","@types/eventsource":"^1.1.6","@types/jest":"^26.0.24","@types/node-fetch":"^2.5.12","@typescript-eslint/eslint-plugin":"^4.29.3","@typescript-eslint/parser":"^4.29.3","babel-jest":"^27.0.6","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^3.4.1","eventsource":"^1.1.0","graphql":"^15.5.1","jest":"^27.0.6","node-fetch":"^2.6.1","prettier":"^2.3.2","replacestream":"^4.0.3","rollup":"^2.56.3","rollup-plugin-terser":"^7.0.2","semantic-release":"^17.4.7","tslib":"^2.3.1","typedoc":"^0.21.6","typedoc-plugin-markdown":"^3.10.4","typescript":"^4.3.5"},"gitHead":"4872a1f63765ac81188e94ddef248ea9c521c1d4","bugs":{"url":"https://github.com/enisdenjo/graphql-sse/issues"},"_id":"graphql-sse@1.0.2","_nodeVersion":"16.8.0","_npmVersion":"7.21.0","dist":{"shasum":"90cd2f3c67608663c8f8fb8282ca5de23935acdf","size":52162,"noattachment":false,"key":"/graphql-sse/-/graphql-sse-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/graphql-sse/download/graphql-sse-1.0.2.tgz"},"_npmUser":{"name":"enisdenjo","email":"badurinadenis@gmail.com"},"directories":{},"maintainers":[{"name":"npm:enisdenjo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-sse_1.0.2_1630005001595_0.33705621552404263"},"_hasShrinkwrap":false,"publish_time":1630005001910,"_cnpm_publish_time":1630005001910},"1.0.1":{"name":"graphql-sse","version":"1.0.1","description":"Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client","keywords":["graphql","client","relay","express","apollo","server","sse","transport","server-sent-events","observables","subscriptions","fastify"],"author":{"name":"Denis Badurina","email":"badurinadenis@gmail.com"},"license":"MIT","homepage":"https://github.com/enisdenjo/graphql-sse#readme","repository":{"type":"git","url":"git+https://github.com/enisdenjo/graphql-sse.git"},"engines":{"node":">=12"},"main":"lib/index.js","module":"lib/index.mjs","browser":"umd/graphql-sse.js","exports":{".":{"require":"./lib/index.js","import":"./lib/index.mjs","browser":"./umd/graphql-sse.js"},"./package.json":"./package.json"},"types":"lib/index.d.ts","sideEffects":["umd/*"],"publishConfig":{"access":"public"},"scripts":{"gendocs":"typedoc --options typedoc.js src/","lint":"eslint 'src'","type-check":"tsc --noEmit","test":"jest","build:esm":"tsc -b tsconfig.esm.json && node scripts/esm-post-process.js","build:cjs":"tsc -b tsconfig.cjs.json","build:umd":"rollup -c && gzip umd/graphql-sse.min.js -c > umd/graphql-sse.min.js.gz","build":"yarn build:esm && yarn build:cjs && yarn build:umd","release":"semantic-release"},"peerDependencies":{"graphql":">=0.11 <=15"},"devDependencies":{"@babel/core":"^7.15.0","@babel/plugin-proposal-class-properties":"^7.14.5","@babel/plugin-proposal-nullish-coalescing-operator":"^7.14.5","@babel/plugin-proposal-object-rest-spread":"^7.14.7","@babel/plugin-proposal-optional-chaining":"^7.14.5","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.15.0","@rollup/plugin-typescript":"^8.2.5","@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","@types/eventsource":"^1.1.6","@types/jest":"^26.0.24","@types/node-fetch":"^2.5.12","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","babel-jest":"^27.0.6","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^3.4.1","eventsource":"^1.1.0","graphql":"^15.5.1","jest":"^27.0.6","node-fetch":"^2.6.1","prettier":"^2.3.2","replacestream":"^4.0.3","rollup":"^2.56.2","rollup-plugin-terser":"^7.0.2","semantic-release":"^17.4.5","typedoc":"^0.21.6","typedoc-plugin-markdown":"^3.10.4","typescript":"^4.3.5"},"gitHead":"dce86d71b1fb54cca1864bf5684085b72eac8e79","bugs":{"url":"https://github.com/enisdenjo/graphql-sse/issues"},"_id":"graphql-sse@1.0.1","_nodeVersion":"16.7.0","_npmVersion":"7.20.3","dist":{"shasum":"d263a8077865b06eaf1b074204683d72a92a5e25","size":51914,"noattachment":false,"key":"/graphql-sse/-/graphql-sse-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/graphql-sse/download/graphql-sse-1.0.1.tgz"},"_npmUser":{"name":"enisdenjo","email":"badurinadenis@gmail.com"},"directories":{},"maintainers":[{"name":"npm:enisdenjo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-sse_1.0.1_1629725833596_0.6395577370438086"},"_hasShrinkwrap":false,"publish_time":1629725833771,"_cnpm_publish_time":1629725833771},"1.0.0":{"name":"graphql-sse","version":"1.0.0","description":"Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client","keywords":["graphql","client","relay","express","apollo","server","sse","transport","server-sent-events","observables","subscriptions","fastify"],"author":{"name":"Denis Badurina","email":"badurinadenis@gmail.com"},"license":"MIT","homepage":"https://github.com/enisdenjo/graphql-sse#readme","repository":{"type":"git","url":"git+https://github.com/enisdenjo/graphql-sse.git"},"engines":{"node":">=12"},"main":"lib/index.js","module":"lib/index.mjs","browser":"umd/graphql-sse.js","exports":{".":{"require":"./lib/index.js","import":"./lib/index.mjs","browser":"./umd/graphql-sse.js"},"./package.json":"./package.json"},"types":"lib/index.d.ts","sideEffects":["umd/*"],"publishConfig":{"access":"public"},"scripts":{"gendocs":"typedoc --options typedoc.js src/","lint":"eslint 'src'","type-check":"tsc --noEmit","test":"jest","build:esm":"tsc -b tsconfig.esm.json && node scripts/esm-post-process.js","build:cjs":"tsc -b tsconfig.cjs.json","build:umd":"rollup -c && gzip umd/graphql-sse.min.js -c > umd/graphql-sse.min.js.gz","build":"yarn build:esm && yarn build:cjs && yarn build:umd","release":"semantic-release"},"peerDependencies":{"graphql":">=0.11 <=15"},"devDependencies":{"@babel/core":"^7.15.0","@babel/plugin-proposal-class-properties":"^7.14.5","@babel/plugin-proposal-nullish-coalescing-operator":"^7.14.5","@babel/plugin-proposal-object-rest-spread":"^7.14.7","@babel/plugin-proposal-optional-chaining":"^7.14.5","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.15.0","@rollup/plugin-typescript":"^8.2.5","@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","@types/eventsource":"^1.1.6","@types/jest":"^26.0.24","@types/node-fetch":"^2.5.12","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","babel-jest":"^27.0.6","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^3.4.1","eventsource":"^1.1.0","graphql":"^15.5.1","jest":"^27.0.6","node-fetch":"^2.6.1","prettier":"^2.3.2","replacestream":"^4.0.3","rollup":"^2.56.2","rollup-plugin-terser":"^7.0.2","semantic-release":"^17.4.5","typedoc":"^0.21.6","typedoc-plugin-markdown":"^3.10.4","typescript":"^4.3.5"},"gitHead":"3feb62c638858effd0e16511a84b382951636253","bugs":{"url":"https://github.com/enisdenjo/graphql-sse/issues"},"_id":"graphql-sse@1.0.0","_nodeVersion":"16.7.0","_npmVersion":"7.20.3","dist":{"shasum":"f954c35487a0d65e7d5f220587d87897caa2c008","size":51833,"noattachment":false,"key":"/graphql-sse/-/graphql-sse-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/graphql-sse/download/graphql-sse-1.0.0.tgz"},"_npmUser":{"name":"enisdenjo","email":"badurinadenis@gmail.com"},"directories":{},"maintainers":[{"name":"npm:enisdenjo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-sse_1.0.0_1629558101407_0.11603297394616274"},"_hasShrinkwrap":false,"publish_time":1629558101523,"_cnpm_publish_time":1629558101523},"0.0.0":{"name":"graphql-sse","version":"0.0.0","license":"ISC","_id":"graphql-sse@0.0.0","_nodeVersion":"14.9.0","_npmVersion":"6.14.7","dist":{"shasum":"c5f36d4635623607c2752b989fe4d14b7e99c442","size":364,"noattachment":false,"key":"/graphql-sse/-/graphql-sse-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/graphql-sse/download/graphql-sse-0.0.0.tgz"},"_npmUser":{"name":"enisdenjo","email":"badurinadenis@gmail.com"},"directories":{},"maintainers":[{"name":"npm:enisdenjo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-sse_0.0.0_1605693556910_0.30167747668725786"},"_hasShrinkwrap":false,"publish_time":1605693557003,"_cnpm_publish_time":1605693557003,"deprecated":"This release was only a name park."}},"readme":"<div align=\"center\">\n  <br />\n\n  <h3>graphql-sse</h3>\n\n  <h6>Zero-dependency, HTTP/1 safe, simple, <a href=\"PROTOCOL.md\">GraphQL over Server-Sent Events Protocol</a> server and client.</h6>\n\n[![Continuous integration](https://github.com/enisdenjo/graphql-sse/workflows/Continuous%20integration/badge.svg)](https://github.com/enisdenjo/graphql-sse/actions?query=workflow%3A%22Continuous+integration%22) [![graphql-sse](https://img.shields.io/npm/v/graphql-sse.svg?label=graphql-sse&logo=npm)](https://www.npmjs.com/package/graphql-sse)\n\n<i>Use [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) instead? Check out <b>[graphql-ws](https://github.com/enisdenjo/graphql-ws)</b>!</i>\n\n  <br />\n</div>\n\n## Getting started\n\n#### Install\n\n```shell\nyarn add graphql-sse\n```\n\n#### Create a GraphQL schema\n\n```ts\nimport { GraphQLSchema, GraphQLObjectType, GraphQLString } from 'graphql';\n\n/**\n * Construct a GraphQL schema and define the necessary resolvers.\n *\n * type Query {\n *   hello: String\n * }\n * type Subscription {\n *   greetings: String\n * }\n */\nconst schema = new GraphQLSchema({\n  query: new GraphQLObjectType({\n    name: 'Query',\n    fields: {\n      hello: {\n        type: GraphQLString,\n        resolve: () => 'world',\n      },\n    },\n  }),\n  subscription: new GraphQLObjectType({\n    name: 'Subscription',\n    fields: {\n      greetings: {\n        type: GraphQLString,\n        subscribe: async function* () {\n          for (const hi of ['Hi', 'Bonjour', 'Hola', 'Ciao', 'Zdravo']) {\n            yield { greetings: hi };\n          }\n        },\n      },\n    },\n  }),\n});\n```\n\n#### Start the server\n\n##### With [`http`](https://nodejs.org/api/http.html)\n\n```ts\nimport http from 'http';\nimport { createHandler } from 'graphql-sse';\n\n// Create the GraphQL over SSE handler\nconst handler = createHandler({\n  schema, // from the previous step\n});\n\n// Create a HTTP server using the handler on `/graphql/stream`\nconst server = http.createServer((req, res) => {\n  if (req.url.startsWith('/graphql/stream')) return handler(req, res);\n  return res.writeHead(404).end();\n});\n\nserver.listen(4000);\nconsole.log('Listening to port 4000');\n```\n\n##### With [`http2`](https://nodejs.org/api/http2.html)\n\n_Browsers might complain about self-signed SSL/TLS certificates. [Help can be found on StackOverflow.](https://stackoverflow.com/questions/7580508/getting-chrome-to-accept-self-signed-localhost-certificate)_\n\n```shell\n$ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \\\n  -keyout localhost-privkey.pem -out localhost-cert.pem\n```\n\n```ts\nimport fs from 'fs';\nimport http2 from 'http2';\nimport { createHandler } from 'graphql-sse';\n\n// Create the GraphQL over SSE handler\nconst handler = createHandler({\n  schema, // from the previous step\n});\n\n// Create a HTTP/2 server using the handler on `/graphql/stream`\nconst server = http2.createSecureServer(\n  {\n    key: fs.readFileSync('localhost-privkey.pem'),\n    cert: fs.readFileSync('localhost-cert.pem'),\n  },\n  (req, res) => {\n    if (req.url.startsWith('/graphql/stream')) return handler(req, res);\n    return res.writeHead(404).end();\n  },\n);\n\nserver.listen(4000);\nconsole.log('Listening to port 4000');\n```\n\n##### With [`express`](https://expressjs.com/)\n\n```ts\nimport express from 'express'; // yarn add express\nimport { createHandler } from 'graphql-sse';\n\n// Create the GraphQL over SSE handler\nconst handler = createHandler({ schema });\n\n// Create an express app serving all methods on `/graphql/stream`\nconst app = express();\napp.use('/graphql/stream', handler);\n\napp.listen(4000);\nconsole.log('Listening to port 4000');\n```\n\n##### With [`fastify`](https://www.fastify.io/)\n\n```ts\nimport Fastify from 'fastify'; // yarn add fastify\nimport { createHandler } from 'graphql-sse';\n\n// Create the GraphQL over SSE handler\nconst handler = createHandler({ schema });\n\n// Create a fastify instance serving all methods on `/graphql/stream`\nconst fastify = Fastify();\nfastify.all('/graphql/stream', (req, res) =>\n  handler(\n    req.raw,\n    res.raw,\n    req.body, // fastify reads the body for you\n  ),\n);\n\nfastify.listen(4000);\nconsole.log('Listening to port 4000');\n```\n\n#### Use the client\n\n```ts\nimport { createClient } from 'graphql-sse';\n\nconst client = createClient({\n  // singleConnection: true, preferred for HTTP/1 enabled servers. read more below\n  url: 'http://localhost:4000/graphql/stream',\n});\n\n// query\n(async () => {\n  const result = await new Promise((resolve, reject) => {\n    let result;\n    client.subscribe(\n      {\n        query: '{ hello }',\n      },\n      {\n        next: (data) => (result = data),\n        error: reject,\n        complete: () => resolve(result),\n      },\n    );\n  });\n\n  expect(result).toEqual({ hello: 'world' });\n})();\n\n// subscription\n(async () => {\n  const onNext = () => {\n    /* handle incoming values */\n  };\n\n  let unsubscribe = () => {\n    /* complete the subscription */\n  };\n\n  await new Promise((resolve, reject) => {\n    unsubscribe = client.subscribe(\n      {\n        query: 'subscription { greetings }',\n      },\n      {\n        next: onNext,\n        error: reject,\n        complete: resolve,\n      },\n    );\n  });\n\n  expect(onNext).toBeCalledTimes(5); // we say \"Hi\" in 5 languages\n})();\n```\n\n## Recipes\n\n<details id=\"promise\">\n<summary><a href=\"#promise\">????</a> Client usage with Promise</summary>\n\n```ts\nimport { createClient, SubscribePayload } from 'graphql-sse';\n\nconst client = createClient({\n  url: 'http://hey.there:4000/graphql/stream',\n});\n\nasync function execute<T>(payload: SubscribePayload) {\n  return new Promise<T>((resolve, reject) => {\n    let result: T;\n    client.subscribe<T>(payload, {\n      next: (data) => (result = data),\n      error: reject,\n      complete: () => resolve(result),\n    });\n  });\n}\n\n// use\n(async () => {\n  try {\n    const result = await execute({\n      query: '{ hello }',\n    });\n    // complete\n    // next = result = { data: { hello: 'Hello World!' } }\n  } catch (err) {\n    // error\n  }\n})();\n```\n\n</details>\n\n<details id=\"async-iterator\">\n<summary><a href=\"#async-iterator\">????</a> Client usage with <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator\">AsyncIterator</a></summary>\n\n```ts\nimport { createClient, SubscribePayload } from 'graphql-sse';\n\nconst client = createClient({\n  url: 'http://iterators.ftw:4000/graphql/stream',\n});\n\nfunction subscribe<T>(payload: SubscribePayload): AsyncGenerator<T> {\n  let deferred: {\n    resolve: (done: boolean) => void;\n    reject: (err: unknown) => void;\n  } | null = null;\n  const pending: T[] = [];\n  let throwMe: unknown = null,\n    done = false;\n  const dispose = client.subscribe<T>(payload, {\n    next: (data) => {\n      pending.push(data);\n      deferred?.resolve(false);\n    },\n    error: (err) => {\n      throwMe = err;\n      deferred?.reject(throwMe);\n    },\n    complete: () => {\n      done = true;\n      deferred?.resolve(true);\n    },\n  });\n  return {\n    [Symbol.asyncIterator]() {\n      return this;\n    },\n    async next() {\n      if (done) return { done: true, value: undefined };\n      if (throwMe) throw throwMe;\n      if (pending.length) return { value: pending.shift()! };\n      return (await new Promise<boolean>(\n        (resolve, reject) => (deferred = { resolve, reject }),\n      ))\n        ? { done: true, value: undefined }\n        : { value: pending.shift()! };\n    },\n    async throw(err) {\n      throw err;\n    },\n    async return() {\n      dispose();\n      return { done: true, value: undefined };\n    },\n  };\n}\n\n(async () => {\n  const subscription = subscribe({\n    query: 'subscription { greetings }',\n  });\n  // subscription.return() to dispose\n\n  for await (const result of subscription) {\n    // next = result = { data: { greetings: 5x } }\n  }\n  // complete\n})();\n```\n\n</details>\n\n<details id=\"observable\">\n<summary><a href=\"#observable\">????</a> Client usage with <a href=\"https://github.com/tc39/proposal-observable\">Observable</a></summary>\n\n```ts\nimport { Observable } from 'relay-runtime';\n// or\nimport { Observable } from '@apollo/client/core';\n// or\nimport { Observable } from 'rxjs';\n// or\nimport Observable from 'zen-observable';\n// or any other lib which implements Observables as per the ECMAScript proposal: https://github.com/tc39/proposal-observable\n\nconst client = createClient({\n  url: 'http://graphql.loves:4000/observables',\n});\n\nfunction toObservable(operation) {\n  return new Observable((observer) =>\n    client.subscribe(operation, {\n      next: (data) => observer.next(data),\n      error: (err) => observer.error(err),\n      complete: () => observer.complete(),\n    }),\n  );\n}\n\nconst observable = toObservable({ query: `subscription { ping }` });\n\nconst subscription = observable.subscribe({\n  next: (data) => {\n    expect(data).toBe({ data: { ping: 'pong' } });\n  },\n});\n\n// ⏱\n\nsubscription.unsubscribe();\n```\n\n</details>\n\n<details id=\"relay\">\n<summary><a href=\"#relay\">????</a> Client usage with <a href=\"https://relay.dev\">Relay</a></summary>\n\n```ts\nimport { GraphQLError } from 'graphql';\nimport {\n  Network,\n  Observable,\n  RequestParameters,\n  Variables,\n} from 'relay-runtime';\nimport { createClient } from 'graphql-sse';\n\nconst subscriptionsClient = createClient({\n  url: 'http://i.love:4000/graphql/stream',\n  headers: () => {\n    const session = getSession();\n    if (!session) return {};\n    return {\n      Authorization: `Bearer ${session.token}`,\n    };\n  },\n});\n\n// yes, both fetch AND subscribe can be handled in one implementation\nfunction fetchOrSubscribe(operation: RequestParameters, variables: Variables) {\n  return Observable.create((sink) => {\n    if (!operation.text) {\n      return sink.error(new Error('Operation text cannot be empty'));\n    }\n    return subscriptionsClient.subscribe(\n      {\n        operationName: operation.name,\n        query: operation.text,\n        variables,\n      },\n      sink,\n    );\n  });\n}\n\nexport const network = Network.create(fetchOrSubscribe, fetchOrSubscribe);\n```\n\n</details>\n\n<details id=\"urql\">\n<summary><a href=\"#urql\">????</a> Client usage with <a href=\"https://formidable.com/open-source/urql/\">urql</a></summary>\n\n```ts\nimport { createClient, defaultExchanges, subscriptionExchange } from 'urql';\nimport { createClient as createWSClient } from 'graphql-sse';\n\nconst sseClient = createWSClient({\n  url: 'http://its.urql:4000/graphql/stream',\n});\n\nconst client = createClient({\n  url: '/graphql/stream',\n  exchanges: [\n    ...defaultExchanges,\n    subscriptionExchange({\n      forwardSubscription(operation) {\n        return {\n          subscribe: (sink) => {\n            const dispose = sseClient.subscribe(operation, sink);\n            return {\n              unsubscribe: dispose,\n            };\n          },\n        };\n      },\n    }),\n  ],\n});\n```\n\n</details>\n\n<details id=\"apollo-client\">\n<summary><a href=\"#apollo-client\">????</a> Client usage with <a href=\"https://www.apollographql.com\">Apollo</a></summary>\n\n```typescript\nimport {\n  ApolloLink,\n  Operation,\n  FetchResult,\n  Observable,\n} from '@apollo/client/core';\nimport { print, GraphQLError } from 'graphql';\nimport { createClient, ClientOptions, Client } from 'graphql-sse';\n\nclass SSELink extends ApolloLink {\n  private client: Client;\n\n  constructor(options: ClientOptions) {\n    super();\n    this.client = createClient(options);\n  }\n\n  public request(operation: Operation): Observable<FetchResult> {\n    return new Observable((sink) => {\n      return this.client.subscribe<FetchResult>(\n        { ...operation, query: print(operation.query) },\n        {\n          next: sink.next.bind(sink),\n          complete: sink.complete.bind(sink),\n          error: sink.error.bind(sink),\n        },\n      );\n    });\n  }\n}\n\nconst link = new SSELink({\n  url: 'http://where.is:4000/graphql/stream',\n  headers: () => {\n    const session = getSession();\n    if (!session) return {};\n    return {\n      Authorization: `Bearer ${session.token}`,\n    };\n  },\n});\n```\n\n</details>\n\n<details id=\"single-connection-mode\">\n<summary><a href=\"#single-connection-mode\">????</a> Client usage for HTTP/1 (aka. <a href=\"https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#single-connection-mode\">single connection mode</a>)</summary>\n\n```typescript\nimport { createClient } from 'graphql-sse';\n\nconst client = createClient({\n  singleConnection: true, // this is literally it ????\n  url: 'http://use.single:4000/connection/graphql/stream',\n  // lazy: true (default) -> connect on first subscribe and disconnect on last unsubscribe\n  // lazy: false -> connect as soon as the client is created\n});\n\n// The client will now run in a \"single connection mode\" mode. Meaning,\n// a single SSE connection will be used to transmit all operation results\n// while separate HTTP requests will be issued to dictate the behaviour.\n```\n\n</details>\n\n<details id=\"retry-strategy\">\n<summary><a href=\"#retry-strategy\">????</a> Client usage with custom retry timeout strategy</summary>\n\n```typescript\nimport { createClient } from 'graphql-sse';\nimport { waitForHealthy } from './my-servers';\n\nconst url = 'http://i.want.retry:4000/control/graphql/stream';\n\nconst client = createClient({\n  url,\n  retryWait: async function waitForServerHealthyBeforeRetry() {\n    // if you have a server healthcheck, you can wait for it to become\n    // healthy before retrying after an abrupt disconnect (most commonly a restart)\n    await waitForHealthy(url);\n\n    // after the server becomes ready, wait for a second + random 1-4s timeout\n    // (avoid DDoSing yourself) and try connecting again\n    await new Promise((resolve) =>\n      setTimeout(resolve, 1000 + Math.random() * 3000),\n    );\n  },\n});\n```\n\n</details>\n\n<details id=\"browser\">\n<summary><a href=\"#browser\">????</a> Client usage in browser</summary>\n\n```html\n<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"utf-8\" />\n    <title>GraphQL over Server-Sent Events</title>\n    <script\n      type=\"text/javascript\"\n      src=\"https://unpkg.com/graphql-sse/umd/graphql-sse.min.js\"\n    ></script>\n  </head>\n  <body>\n    <script type=\"text/javascript\">\n      const client = graphqlSse.createClient({\n        url: 'http://umdfor.the:4000/win/graphql/stream',\n      });\n\n      // consider other recipes for usage inspiration\n    </script>\n  </body>\n</html>\n```\n\n</details>\n\n<details id=\"node-client\">\n<summary><a href=\"#node-client\">????</a> Client usage in Node</summary>\n\n```ts\nconst ws = require('ws'); // yarn add ws\nconst fetch = require('node-fetch'); // yarn add node-fetch\nconst { AbortController } = require('node-abort-controller'); // (node < v15) yarn add node-abort-controller\nconst Crypto = require('crypto');\nconst { createClient } = require('graphql-sse');\n\nconst client = createClient({\n  url: 'http://no.browser:4000/graphql/stream',\n  fetchFn: fetch,\n  abortControllerImpl: AbortController, // node < v15\n  /**\n   * Generates a v4 UUID to be used as the ID.\n   * Reference: https://gist.github.com/jed/982883\n   */\n  generateID: () =>\n    ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>\n      (c ^ (Crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16),\n    ),\n});\n\n// consider other recipes for usage inspiration\n```\n\n</details>\n\n<details id=\"auth\">\n<summary><a href=\"#schema\">????</a> Server handler usage with custom authentication</summary>\n\n```typescript\nimport { createHandler } from 'graphql-sse';\nimport {\n  schema,\n  getOrCreateTokenFromCookies,\n  customAuthenticationTokenDiscovery,\n  processAuthorizationHeader,\n} from './my-graphql';\n\nconst handler = createHandler({\n  schema,\n  authenticate: async (req, res) => {\n    let token = req.headers['x-graphql-event-stream-token'];\n    if (token) {\n      // When the client is working in a \"single connection mode\"\n      // all subsequent requests for operations will have the\n      // stream token set in the `X-GraphQL-Event-Stream-Token` header.\n      //\n      // It is considered safe to accept the header token always\n      // because if a stream reservation does not exist, or is already\n      // fulfilled, the handler itself will reject the request.\n      //\n      // Read more: https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#single-connection-mode\n      return Array.isArray(token) ? token.join('') : token;\n    }\n\n    // It is necessary to generate a unique token when dealing with\n    // clients that operate in the \"single connection mode\". The process\n    // of generating the token is completely up to the implementor.\n    token = getOrCreateTokenFromCookies(req);\n    // or\n    token = processAuthorizationHeader(req.headers['authorization']);\n    // or\n    token = await customAuthenticationTokenDiscovery(req);\n\n    // Using the response argument the implementor may respond to\n    // authentication issues however he sees fit.\n    if (!token) return res.writeHead(401, 'Unauthorized').end();\n\n    // Clients that operate in \"distinct connections mode\" dont\n    // need a unique stream token. It is completely ok to simply\n    // return an empty string for authenticated clients.\n    //\n    // Read more: https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#distinct-connections-mode\n    if (req.method === 'POST' && req.headers.accept === 'text/event-stream') {\n      // \"distinct connections mode\" requests an event-stream with a POST\n      // method. These two checks, together with the lack of `X-GraphQL-Event-Stream-Token`\n      // header, are sufficient for accurate detection.\n      return ''; // return token; is OK too\n    }\n\n    // On the other hand, clients operating in \"single connection mode\"\n    // need a unique stream token which will be provided alongside the\n    // incoming event stream request inside the `X-GraphQL-Event-Stream-Token` header.\n    //\n    // Read more: https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#single-connection-mode\n    return token;\n  },\n});\n\n// use `handler` with your favourite http library\n```\n\n</details>\n\n<details id=\"dynamic-schema\">\n<summary><a href=\"#dynamic-schema\">????</a> Server handler usage with dynamic schema</summary>\n\n```typescript\nimport { createHandler } from 'graphql-sse';\nimport { schema, checkIsAdmin, getDebugSchema } from './my-graphql';\n\nconst handler = createHandler({\n  schema: async (req, executionArgsWithoutSchema) => {\n    // will be called on every subscribe request\n    // allowing you to dynamically supply the schema\n    // using the depending on the provided arguments\n    const isAdmin = await checkIsAdmin(req);\n    if (isAdmin) return getDebugSchema(req, executionArgsWithoutSchema);\n    return schema;\n  },\n});\n\n// use `handler` with your favourite http library\n```\n\n</details>\n\n<details id=\"context\">\n<summary><a href=\"#context\">????</a> Server handler usage with custom context value</summary>\n\n```typescript\nimport { createHandler } from 'graphql-sse';\nimport { schema, getDynamicContext } from './my-graphql';\n\nconst handler = createHandler({\n  schema,\n  // or static context by supplying the value direcly\n  context: async (req, args) => {\n    return getDynamicContext(req, args);\n  },\n});\n\n// use `handler` with your favourite http library\n```\n\n</details>\n\n<details id=\"custom-exec\">\n<summary><a href=\"#custom-exec\">????</a> Server handler usage with custom execution arguments</summary>\n\n```typescript\nimport { parse } from 'graphql';\nimport { createHandler } from 'graphql-sse';\nimport { getSchema, myValidationRules } from './my-graphql';\n\nconst handler = createHandler({\n  onSubscribe: async (req, _res, params) => {\n    const schema = await getSchema(req);\n\n    const args = {\n      schema,\n      operationName: params.operationName,\n      document: parse(params.query),\n      variableValues: params.variables,\n    };\n\n    return args;\n  },\n});\n\n// use `handler` with your favourite http library\n```\n\n</details>\n\n<details id=\"persisted\">\n<summary><a href=\"#persisted\">????</a> Server handler and client usage with persisted queries</summary>\n\n```typescript\n// ???? server\n\nimport { parse, ExecutionArgs } from 'graphql';\nimport { createHandler } from 'graphql-sse';\nimport { schema } from './my-graphql-schema';\n\n// a unique GraphQL execution ID used for representing\n// a query in the persisted queries store. when subscribing\n// you should use the `SubscriptionPayload.query` to transmit the id\ntype QueryID = string;\n\nconst queriesStore: Record<QueryID, ExecutionArgs> = {\n  iWantTheGreetings: {\n    schema, // you may even provide different schemas in the queries store\n    document: parse('subscription Greetings { greetings }'),\n  },\n};\n\nconst handler = createHandler(\n  {\n    onSubscribe: (req, res, params) => {\n      const persistedQuery = queriesStore[params.extensions?.persistedQuery];\n      if (persistedQuery) {\n        return {\n          ...persistedQuery,\n          variableValues: params.variables, // use the variables from the client\n        };\n      }\n\n      // for extra security only allow the queries from the store\n      return res.writeHead(404, 'Query Not Found').end();\n    },\n  },\n  wsServer,\n);\n\n// use `handler` with your favourite http library\n```\n\n```typescript\n// ???? client\n\nimport { createClient } from 'graphql-sse';\n\nconst client = createClient({\n  url: 'http://persisted.graphql:4000/queries',\n});\n\n(async () => {\n  const onNext = () => {\n    /**/\n  };\n\n  await new Promise((resolve, reject) => {\n    client.subscribe(\n      {\n        query: '', // query field is required, but you can leave it empty for persisted queries\n        extensions: {\n          persistedQuery: 'iWantTheGreetings',\n        },\n      },\n      {\n        next: onNext,\n        error: reject,\n        complete: resolve,\n      },\n    );\n  });\n\n  expect(onNext).toBeCalledTimes(5); // greetings in 5 languages\n})();\n```\n\n</details>\n\n## [Documentation](docs/)\n\nCheck the [docs folder](docs/) out for [TypeDoc](https://typedoc.org) generated documentation.\n\n## [How does it work?](PROTOCOL.md)\n\nRead about the exact transport intricacies used by the library in the [GraphQL over Server-Sent Events Protocol document](PROTOCOL.md).\n\n## [Want to help?](CONTRIBUTING.md)\n\nFile a bug, contribute with code, or improve documentation? Read up on our guidelines for [contributing](CONTRIBUTING.md) and drive development with `yarn test --watch` away!\n","_attachments":{},"homepage":"https://github.com/enisdenjo/graphql-sse#readme","bugs":{"url":"https://github.com/enisdenjo/graphql-sse/issues"},"license":"MIT"}