graphql-sse
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -8,3 +8,3 @@ /** | ||
import type { IncomingMessage, ServerResponse } from 'http'; | ||
import { DocumentNode, ExecutionArgs, ExecutionResult, GraphQLError, GraphQLSchema, TypeInfo, ValidationRule } from 'graphql'; | ||
import { ExecutionArgs, ExecutionResult, GraphQLSchema, validate as graphqlValidate } from 'graphql'; | ||
import { RequestParams } from './common'; | ||
@@ -54,5 +54,3 @@ /** | ||
*/ | ||
validate?: (schema: GraphQLSchema, documentAST: DocumentNode, rules?: ReadonlyArray<ValidationRule>, typeInfo?: TypeInfo, options?: { | ||
maxErrors?: number; | ||
}) => ReadonlyArray<GraphQLError>; | ||
validate?: typeof graphqlValidate; | ||
/** | ||
@@ -59,0 +57,0 @@ * Is the `execute` function from GraphQL which is |
MIT License | ||
Copyright (c) 2020 Denis Badurina | ||
Copyright (c) 2021 Denis Badurina | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "graphql-sse", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client", | ||
@@ -82,4 +82,4 @@ "keywords": [ | ||
"@types/node-fetch": "^2.5.12", | ||
"@typescript-eslint/eslint-plugin": "^4.29.2", | ||
"@typescript-eslint/parser": "^4.29.2", | ||
"@typescript-eslint/eslint-plugin": "^4.29.3", | ||
"@typescript-eslint/parser": "^4.29.3", | ||
"babel-jest": "^27.0.6", | ||
@@ -95,5 +95,6 @@ "eslint": "^7.32.0", | ||
"replacestream": "^4.0.3", | ||
"rollup": "^2.56.2", | ||
"rollup": "^2.56.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"semantic-release": "^17.4.5", | ||
"semantic-release": "^17.4.7", | ||
"tslib": "^2.3.1", | ||
"typedoc": "^0.21.6", | ||
@@ -100,0 +101,0 @@ "typedoc-plugin-markdown": "^3.10.4", |
@@ -85,2 +85,37 @@ <div align="center"> | ||
##### With [`http2`](https://nodejs.org/api/http2.html) | ||
_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)_ | ||
```shell | ||
$ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \ | ||
-keyout localhost-privkey.pem -out localhost-cert.pem | ||
``` | ||
```ts | ||
import fs from 'fs'; | ||
import http2 from 'http2'; | ||
import { createHandler } from 'graphql-sse'; | ||
// Create the GraphQL over SSE handler | ||
const handler = createHandler({ | ||
schema, // from the previous step | ||
}); | ||
// Create a HTTP/2 server using the handler on `/graphql/stream` | ||
const server = http2.createSecureServer( | ||
{ | ||
key: fs.readFileSync('localhost-privkey.pem'), | ||
cert: fs.readFileSync('localhost-cert.pem'), | ||
}, | ||
(req, res) => { | ||
if (req.url.startsWith('/graphql/stream')) return handler(req, res); | ||
return res.writeHead(404).end(); | ||
}, | ||
); | ||
server.listen(4000); | ||
console.log('Listening to port 4000'); | ||
``` | ||
##### With [`express`](https://expressjs.com/) | ||
@@ -97,3 +132,3 @@ | ||
const app = express(); | ||
app.all('/graphql/stream', handler); | ||
app.use('/graphql/stream', handler); | ||
@@ -133,3 +168,4 @@ app.listen(4000); | ||
const client = createClient({ | ||
url: 'http://welcomer.com:4000/graphql/stream', | ||
// singleConnection: true, use "single connection mode" instead of the default "distinct connection mode" | ||
url: 'http://localhost:4000/graphql/stream', | ||
}); | ||
@@ -136,0 +172,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204151
826
32
3587