apollo-server-core
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -69,2 +69,5 @@ "use strict"; | ||
} | ||
function isFunction(arg) { | ||
return typeof arg === 'function'; | ||
} | ||
function runHttpQuery(handlerArguments, request) { | ||
@@ -91,3 +94,3 @@ return __awaiter(this, void 0, void 0, function () { | ||
case 'POST': | ||
if (!request.query) { | ||
if (!request.query || (Object.keys(request.query).length === 0)) { | ||
throw new HttpQueryError(500, 'POST body missing. Did you forget use body-parser middleware?'); | ||
@@ -137,6 +140,9 @@ } | ||
} | ||
var context_1 = optionsObject.context; | ||
if (isBatch) { | ||
context_1 = Object.assign({}, context_1 || {}); | ||
var context_1 = optionsObject.context || {}; | ||
if (isFunction(context_1)) { | ||
context_1 = context_1(); | ||
} | ||
else if (isBatch) { | ||
context_1 = Object.assign(Object.create(Object.getPrototypeOf(context_1)), context_1); | ||
} | ||
var params = { | ||
@@ -143,0 +149,0 @@ schema: optionsObject.schema, |
{ | ||
"name": "apollo-server-core", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Core engine for Apollo GraphQL server", | ||
@@ -32,3 +32,3 @@ "main": "dist/index.js", | ||
"meteor-promise": "0.8.6", | ||
"typescript": "^2.5.3" | ||
"typescript": "2.6.2" | ||
}, | ||
@@ -35,0 +35,0 @@ "peerDependencies": { |
@@ -1,3 +0,3 @@ | ||
# graphql-server-core | ||
# apollo-server-core | ||
This is the core module of the Apollo community GraphQL Server. [Read the docs.](http://dev.apollodata.com/tools/apollo-server/index.html) | ||
This is the core module of the Apollo community GraphQL Server. [Read the docs.](https://www.apollographql.com/docs/apollo-server/) |
@@ -30,2 +30,6 @@ import { parse, getOperationAST, DocumentNode, formatError, ExecutionResult } from 'graphql'; | ||
function isFunction(arg: any): arg is Function { | ||
return typeof arg === 'function'; | ||
} | ||
export async function runHttpQuery(handlerArguments: Array<any>, request: HttpQueryRequest): Promise<string> { | ||
@@ -45,3 +49,3 @@ let isGetRequest: boolean = false; | ||
case 'POST': | ||
if ( !request.query ) { | ||
if ( !request.query || (Object.keys(request.query).length === 0) ) { | ||
throw new HttpQueryError(500, 'POST body missing. Did you forget use body-parser middleware?'); | ||
@@ -102,8 +106,7 @@ } | ||
// Shallow clone context for queries in batches. This allows | ||
// users to distinguish multiple queries in the batch and to | ||
// modify the context object without interfering with each other. | ||
let context = optionsObject.context; | ||
if (isBatch) { | ||
context = Object.assign({}, context || {}); | ||
let context = optionsObject.context || {}; | ||
if (isFunction(context)) { | ||
context = context(); | ||
} else if (isBatch) { | ||
context = Object.assign(Object.create(Object.getPrototypeOf(context)), context); | ||
} | ||
@@ -115,3 +118,3 @@ | ||
variables: variables, | ||
context: context, | ||
context, | ||
rootValue: optionsObject.rootValue, | ||
@@ -118,0 +121,0 @@ operationName: operationName, |
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
57361
1125