Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-http

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-http - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

8

lib/handler.d.ts

@@ -35,4 +35,10 @@ /**

readonly headers: RequestHeaders;
readonly body: string | Record<string, unknown> | null;
/**
* Parsed request body or a parser function.
*
* If the provided function throws, the error message "Unparsable JSON body" will
* be in the erroneous response.
*/
readonly body: string | Record<string, unknown> | null | (() => string | Record<string, unknown> | null | Promise<string | Record<string, unknown> | null>);
/**
* The raw request itself from the implementing server.

@@ -39,0 +45,0 @@ *

19

lib/handler.js

@@ -145,12 +145,17 @@ "use strict";

}
let data;
try {
const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body;
partParams.operationName = data.operationName;
partParams.query = data.query;
partParams.variables = data.variables;
partParams.extensions = data.extensions;
const body = typeof req.body === 'function' ? await req.body() : req.body;
data = typeof body === 'string' ? JSON.parse(body) : body;
}
catch (_d) {
catch (err) {
throw new Error('Unparsable JSON body');
}
if (!(0, utils_1.isObject)(data)) {
throw new Error('JSON body must be an object');
}
partParams.operationName = data.operationName;
partParams.query = data.query;
partParams.variables = data.variables;
partParams.extensions = data.extensions;
break;

@@ -233,3 +238,3 @@ }

}
catch (_e) {
catch (_d) {
return makeResponse(new graphql_1.GraphQLError('Unable to detect operation AST'), acceptedMediaType);

@@ -236,0 +241,0 @@ }

@@ -8,3 +8,3 @@ /**

/** @private */
export declare function isObject(val: unknown): val is Record<PropertyKey, unknown>;
export declare function isObject(val: unknown): val is Record<PropertyKey, any>;
/** @private */

@@ -11,0 +11,0 @@ export declare function areGraphQLErrors(obj: unknown): obj is readonly GraphQLError[];

{
"name": "graphql-http",
"version": "1.3.0",
"version": "1.4.0",
"description": "Simple, pluggable, zero-dependency, GraphQL over HTTP Protocol compliant server and client",

@@ -5,0 +5,0 @@ "keywords": [

@@ -193,7 +193,3 @@ <div align="center">

headers: req.headers,
body: await new Promise((resolve) => {
let body = '';
req.on('data', (chunk) => (body += chunk));
req.on('end', () => resolve(body));
}),
body: req.body, // fastify reads the body for you
raw: req,

@@ -200,0 +196,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc