From c609a6d5f378afeb8a5b96f40e08d68247f0d111 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Mon, 1 Jun 2020 03:12:47 +0300 Subject: [PATCH] Make few check more explicit --- src/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index a319b447..94a86023 100644 --- a/src/index.js +++ b/src/index.js @@ -357,11 +357,15 @@ function graphqlHTTP(options: Options): Middleware { // Note: Information about the error itself will still be contained in // the resulting JSON payload. // https://graphql.github.io/graphql-spec/#sec-Data - if (response.statusCode === 200 && result && !result.data) { + if ( + response.statusCode === 200 && + result != null && + result.data == null + ) { response.statusCode = 500; } // Format any encountered errors. - if (result && result.errors) { + if (result?.errors) { (result: any).errors = result.errors.map(formatErrorFn); } @@ -443,7 +447,8 @@ export type GraphQLParams = {| module.exports.getGraphQLParams = getGraphQLParams; async function getGraphQLParams(request: $Request): Promise { const bodyData = await parseBody(request); - const urlData = (request.url && url.parse(request.url, true).query) || {}; + const urlData = + (request.url != null && url.parse(request.url, true).query) || {}; return parseGraphQLParams(urlData, bodyData); }