Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
Make few check more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jun 1, 2020
1 parent bc492e4 commit c609a6d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -443,7 +447,8 @@ export type GraphQLParams = {|
module.exports.getGraphQLParams = getGraphQLParams;
async function getGraphQLParams(request: $Request): Promise<GraphQLParams> {
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);
}
Expand Down

0 comments on commit c609a6d

Please sign in to comment.