graphql-http
Advanced tools
Comparing version 1.18.0 to 1.19.0
@@ -24,3 +24,2 @@ "use strict"; | ||
function createHandler(options) { | ||
const isProd = process.env.NODE_ENV === 'production'; | ||
const handle = (0, handler_1.createHandler)(options); | ||
@@ -54,19 +53,3 @@ return async function requestListener(req, res) { | ||
'Please check your implementation.', err); | ||
if (isProd) { | ||
res.writeHead(500).end(); | ||
} | ||
else { | ||
res | ||
.writeHead(500, { 'content-type': 'application/json; charset=utf-8' }) | ||
.end(JSON.stringify({ | ||
errors: [ | ||
err instanceof Error | ||
? { | ||
message: err.message, | ||
stack: err.stack, | ||
} | ||
: err, | ||
], | ||
})); | ||
} | ||
res.writeHead(500).end(); | ||
} | ||
@@ -73,0 +56,0 @@ }; |
@@ -24,3 +24,2 @@ "use strict"; | ||
function createHandler(options) { | ||
const isProd = process.env.NODE_ENV === 'production'; | ||
const handle = (0, handler_1.createHandler)(options); | ||
@@ -49,20 +48,3 @@ return async function requestListener(req, reply) { | ||
'Please check your implementation.', err); | ||
if (isProd) { | ||
reply.status(500).send(); | ||
} | ||
else { | ||
reply | ||
.status(500) | ||
.header('content-type', 'application/json; charset=utf-8') | ||
.send({ | ||
errors: [ | ||
err instanceof Error | ||
? { | ||
message: err.message, | ||
stack: err.stack, | ||
} | ||
: err, | ||
], | ||
}); | ||
} | ||
reply.status(500).send(); | ||
} | ||
@@ -69,0 +51,0 @@ }; |
@@ -29,3 +29,3 @@ import { HandlerOptions as RawHandlerOptions, OperationContext } from '../handler'; | ||
* import { createHandler } from 'graphql-http/lib/use/fetch'; | ||
* import { schema } from './my-graphql-step'; | ||
* import { schema } from './my-graphql-schema'; | ||
* | ||
@@ -32,0 +32,0 @@ * // Use this adapter in _any_ environment. |
@@ -16,3 +16,3 @@ "use strict"; | ||
* import { createHandler } from 'graphql-http/lib/use/fetch'; | ||
* import { schema } from './my-graphql-step'; | ||
* import { schema } from './my-graphql-schema'; | ||
* | ||
@@ -35,3 +35,2 @@ * // Use this adapter in _any_ environment. | ||
function createHandler(options, reqCtx = {}) { | ||
const isProd = process.env.NODE_ENV === 'production'; | ||
const api = { | ||
@@ -60,22 +59,3 @@ Response: reqCtx.Response || Response, | ||
'Please check your implementation.', err); | ||
if (isProd) { | ||
return new api.Response(null, { status: 500 }); | ||
} | ||
else { | ||
return new api.Response(JSON.stringify({ | ||
errors: [ | ||
err instanceof Error | ||
? { | ||
message: err.message, | ||
stack: err.stack, | ||
} | ||
: err, | ||
], | ||
}), { | ||
status: 500, | ||
headers: { | ||
'content-type': 'application/json; charset=utf-8', | ||
}, | ||
}); | ||
} | ||
return new api.Response(null, { status: 500 }); | ||
} | ||
@@ -82,0 +62,0 @@ }; |
@@ -25,3 +25,3 @@ /// <reference types="node" /> | ||
* import { createHandler } from 'graphql-http/lib/use/http'; | ||
* import { schema } from './my-graphql-step'; | ||
* import { schema } from './my-graphql-schema'; | ||
* | ||
@@ -28,0 +28,0 @@ * const server = http.createServer(createHandler({ schema })); |
@@ -12,3 +12,3 @@ "use strict"; | ||
* import { createHandler } from 'graphql-http/lib/use/http'; | ||
* import { schema } from './my-graphql-step'; | ||
* import { schema } from './my-graphql-schema'; | ||
* | ||
@@ -24,3 +24,2 @@ * const server = http.createServer(createHandler({ schema })); | ||
function createHandler(options) { | ||
const isProd = process.env.NODE_ENV === 'production'; | ||
const handle = (0, handler_1.createHandler)(options); | ||
@@ -54,19 +53,3 @@ return async function requestListener(req, res) { | ||
'Please check your implementation.', err); | ||
if (isProd) { | ||
res.writeHead(500).end(); | ||
} | ||
else { | ||
res | ||
.writeHead(500, { 'content-type': 'application/json; charset=utf-8' }) | ||
.end(JSON.stringify({ | ||
errors: [ | ||
err instanceof Error | ||
? { | ||
message: err.message, | ||
stack: err.stack, | ||
} | ||
: err, | ||
], | ||
})); | ||
} | ||
res.writeHead(500).end(); | ||
} | ||
@@ -73,0 +56,0 @@ }; |
@@ -31,3 +31,3 @@ /// <reference types="node" /> | ||
* import { createHandler } from 'graphql-http/lib/use/http2'; | ||
* import { schema } from './my-graphql-step'; | ||
* import { schema } from './my-graphql-schema'; | ||
* | ||
@@ -34,0 +34,0 @@ * const server = http2.createSecureServer( |
@@ -18,3 +18,3 @@ "use strict"; | ||
* import { createHandler } from 'graphql-http/lib/use/http2'; | ||
* import { schema } from './my-graphql-step'; | ||
* import { schema } from './my-graphql-schema'; | ||
* | ||
@@ -36,3 +36,2 @@ * const server = http2.createSecureServer( | ||
function createHandler(options) { | ||
const isProd = process.env.NODE_ENV === 'production'; | ||
const handle = (0, handler_1.createHandler)(options); | ||
@@ -72,19 +71,3 @@ return async function requestListener(req, res) { | ||
'Please check your implementation.', err); | ||
if (isProd) { | ||
res.writeHead(500).end(); | ||
} | ||
else { | ||
res | ||
.writeHead(500, { 'content-type': 'application/json; charset=utf-8' }) | ||
.end(JSON.stringify({ | ||
errors: [ | ||
err instanceof Error | ||
? { | ||
message: err.message, | ||
stack: err.stack, | ||
} | ||
: err, | ||
], | ||
})); | ||
} | ||
res.writeHead(500).end(); | ||
} | ||
@@ -91,0 +74,0 @@ }; |
@@ -25,3 +25,2 @@ "use strict"; | ||
function createHandler(options) { | ||
const isProd = process.env.NODE_ENV === 'production'; | ||
const handle = (0, handler_1.createHandler)(options); | ||
@@ -63,15 +62,2 @@ return async function requestListener(ctx) { | ||
ctx.response.status = 500; | ||
if (!isProd) { | ||
ctx.response.set('content-type', 'application/json; charset=utf-8'); | ||
ctx.body = { | ||
errors: [ | ||
err instanceof Error | ||
? { | ||
message: err.message, | ||
stack: err.stack, | ||
} | ||
: err, | ||
], | ||
}; | ||
} | ||
} | ||
@@ -78,0 +64,0 @@ }; |
@@ -19,3 +19,3 @@ /// <reference types="node" /> | ||
* import { createHandler } from 'graphql-http/lib/use/node'; | ||
* import { schema } from './my-graphql-step'; | ||
* import { schema } from './my-graphql-schema'; | ||
* | ||
@@ -22,0 +22,0 @@ * const server = http.createServer(createHandler({ schema })); |
@@ -12,3 +12,3 @@ "use strict"; | ||
* import { createHandler } from 'graphql-http/lib/use/node'; | ||
* import { schema } from './my-graphql-step'; | ||
* import { schema } from './my-graphql-schema'; | ||
* | ||
@@ -15,0 +15,0 @@ * const server = http.createServer(createHandler({ schema })); |
{ | ||
"name": "graphql-http", | ||
"version": "1.18.0", | ||
"version": "1.19.0", | ||
"description": "Simple, pluggable, zero-dependency, GraphQL over HTTP spec compliant server, client and audit suite.", | ||
@@ -27,3 +27,3 @@ "keywords": [ | ||
}, | ||
"packageManager": "yarn@3.5.0", | ||
"packageManager": "yarn@3.6.0", | ||
"main": "lib/index.js", | ||
@@ -74,2 +74,7 @@ "module": "lib/index.mjs", | ||
}, | ||
"./lib/use/uWebSockets": { | ||
"types": "./lib/use/uWebSockets.d.ts", | ||
"require": "./lib/use/uWebSockets.js", | ||
"import": "./lib/use/uWebSockets.mjs" | ||
}, | ||
"./package.json": "./package.json" | ||
@@ -111,3 +116,3 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.21.4", | ||
"@babel/core": "^7.22.1", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
@@ -117,24 +122,25 @@ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", | ||
"@babel/plugin-proposal-optional-chaining": "^7.21.0", | ||
"@babel/preset-env": "^7.21.4", | ||
"@babel/preset-typescript": "^7.21.4", | ||
"@rollup/plugin-terser": "^0.4.1", | ||
"@rollup/plugin-typescript": "^11.1.0", | ||
"@babel/preset-env": "^7.22.4", | ||
"@babel/preset-typescript": "^7.21.5", | ||
"@rollup/plugin-terser": "^0.4.3", | ||
"@rollup/plugin-typescript": "^11.1.1", | ||
"@semantic-release/changelog": "^6.0.3", | ||
"@semantic-release/git": "^10.0.1", | ||
"@types/eslint": "^8.37.0", | ||
"@types/eslint": "^8.40.0", | ||
"@types/express": "^4.17.17", | ||
"@types/glob": "^8.1.0", | ||
"@types/html-validator": "^5.0.3", | ||
"@types/jest": "^29.5.0", | ||
"@types/jest": "^29.5.2", | ||
"@types/k6": "^0.44.2", | ||
"@types/koa": "^2.13.6", | ||
"@types/koa-mount": "^4.0.2", | ||
"@typescript-eslint/eslint-plugin": "^5.58.0", | ||
"@typescript-eslint/parser": "^5.58.0", | ||
"@whatwg-node/fetch": "^0.8.4", | ||
"@typescript-eslint/eslint-plugin": "^5.59.8", | ||
"@typescript-eslint/parser": "^5.59.8", | ||
"@whatwg-node/fetch": "^0.9.2", | ||
"babel-jest": "^29.5.0", | ||
"eslint": "^8.38.0", | ||
"eslint": "^8.42.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"express": "^4.18.2", | ||
"fastify": "^4.15.0", | ||
"glob": "^10.0.0", | ||
"fastify": "^4.17.0", | ||
"glob": "^10.2.6", | ||
"graphql": "^16.6.0", | ||
@@ -147,14 +153,12 @@ "html-validator": "^6.0.1", | ||
"node-fetch": "^3.3.1", | ||
"prettier": "^2.8.7", | ||
"rollup": "^3.20.2", | ||
"prettier": "^2.8.8", | ||
"rollup": "^3.23.1", | ||
"rollup-plugin-gzip": "^3.1.0", | ||
"semantic-release": "^21.0.1", | ||
"tslib": "^2.5.0", | ||
"typedoc": "^0.24.1", | ||
"typedoc-plugin-markdown": "^3.15.1", | ||
"typescript": "^5.0.4" | ||
}, | ||
"resolutions": { | ||
"npm/libnpmversion": "^3.0.6" | ||
"semantic-release": "^21.0.3", | ||
"tslib": "^2.5.3", | ||
"typedoc": "^0.24.8", | ||
"typedoc-plugin-markdown": "^3.15.3", | ||
"typescript": "^5.1.3", | ||
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.30.0" | ||
} | ||
} |
@@ -161,2 +161,17 @@ <div align="center"> | ||
##### With [`uWebSockets.js`](https://github.com/uNetworking/uWebSockets.js) | ||
```js | ||
import uWS from 'uWebSockets.js'; // yarn add uWebSockets.js@uNetworking/uWebSockets.js#<version> | ||
import { createHandler } from 'graphql-http/lib/use/uWebSockets'; | ||
import { schema } from './previous-step'; | ||
uWS | ||
.App() | ||
.any('/graphql', createHandler({ schema })) | ||
.listen(4000, () => { | ||
console.log('Listening to port 4000'); | ||
}); | ||
``` | ||
##### With [`Deno`](https://deno.land/) | ||
@@ -772,3 +787,3 @@ | ||
This is the official [GraphQL over HTTP spec](https://graphql.github.io/graphql-over-http/) reference implementation and as such follows the specification strictly without any additional features (like file uploads, @stream/@defer directives and subscriptions). | ||
This is the official [GraphQL over HTTP spec](https://graphql.github.io/graphql-over-http/) reference implementation and as such follows the specification strictly without any additional features (like playgrounds or GUIs, file uploads, @stream/@defer directives and subscriptions). | ||
@@ -775,0 +790,0 @@ Having said this, graphql-http is mostly aimed for library authors and simple server setups, where the requirements are exact to what the aforementioned spec offers. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
338462
81
827
0
44
6274