New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koa-graphql

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-graphql - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

PATENTS

4

dist/index.js

@@ -63,3 +63,3 @@ 'use strict';

try {
data = yield parseBody(req);
data = yield parseBody(req, request);
data = data || {};

@@ -90,3 +90,3 @@

response.status = result.hasOwnProperty('data') ? 200 : 400;
response.type = 'text/json';
response.type = 'application/json';
response.body = JSON.stringify(result, null, pretty ? 2 : 0);

@@ -93,0 +93,0 @@ };

@@ -30,6 +30,6 @@ 'use strict';

function parseBody(req, next) {
function parseBody(req, request, next) {
try {
// If express has already parsed a body, use it.
if (typeof req.body === 'object') {
// If koa has already parsed a body as a keyed object, use it.
if (typeof req.body === 'object' && !(req.body instanceof Buffer)) {
return next(null, req.body);

@@ -45,2 +45,13 @@ }

// If koa has already parsed a body as a string, and the content-type
// was application/graphql, parse the string body.
if (typeof request.body === 'string' && typeInfo.type === 'application/graphql') {
return next(null, graphqlParser(request.body));
}
// Already parsed body we didn't recognise? Parse nothing.
if (request.body) {
return next();
}
// Use the correct body parser based on Content-Type header.

@@ -47,0 +58,0 @@ switch (typeInfo.type) {

{
"name": "koa-graphql",
"version": "0.2.0",
"version": "0.3.0",
"description": "Create a GraphQL HTTP server with Koa.",

@@ -56,3 +56,3 @@ "contributors": [

"peerDependencies": {
"graphql": "^0.4.2"
"graphql": "^0.4.5"
},

@@ -62,11 +62,13 @@ "devDependencies": {

"babel-core": "^5.8.21",
"babel-eslint": "^4.0.5",
"babel-eslint": "^4.1.3",
"babel-runtime": "^5.8.20",
"chai": "^3.2.0",
"co-body": "^4.0.0",
"coveralls": "^2.11.3",
"eslint": "^1.1.0",
"eslint-plugin-babel": "^2.1.1",
"flow-bin": "^0.14.0",
"graphql": "^0.4.2",
"graphql": "^0.4.5",
"isparta": "^3.0.3",
"koa": "^0.21.0",
"koa": "^1.0.0",
"koa-mount": "^1.3.0",

@@ -76,3 +78,3 @@ "mocha": "^2.2.5",

"sane": "^1.1.3",
"supertest": "^1.0.1",
"supertest": "1.0.1",
"supertest-as-promised": "^2.0.2",

@@ -79,0 +81,0 @@ "thenify": "^3.1.0"

@@ -44,3 +44,3 @@ # GraphQL Koa Middleware

operations, this specifies which operation should be executed. If not
provided, an 400 error will be returned if the `query` contains multiple
provided, a 400 error will be returned if the `query` contains multiple
named operations.

@@ -59,3 +59,3 @@

for `multipart/form-data` content, which may be useful for GraphQL mutations
involving uploading files.
involving uploading files. See an [example using multer](https://github.com/chentsulin/koa-graphql/blob/master/src/__tests__/http-test.js#L458).

@@ -74,3 +74,10 @@ If the POST body has not yet been parsed, graphql-express will interpret it

### Contributing
Welcome pull requests!
### License
BSD-3-Clause
[`graphql-js`]: https://github.com/graphql/graphql-js

@@ -77,0 +84,0 @@ [`multer`]: https://github.com/expressjs/multer

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