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

Commit c609a6d

Browse files
committed
Make few check more explicit
1 parent bc492e4 commit c609a6d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,15 @@ function graphqlHTTP(options: Options): Middleware {
357357
// Note: Information about the error itself will still be contained in
358358
// the resulting JSON payload.
359359
// https://graphql.github.io/graphql-spec/#sec-Data
360-
if (response.statusCode === 200 && result && !result.data) {
360+
if (
361+
response.statusCode === 200 &&
362+
result != null &&
363+
result.data == null
364+
) {
361365
response.statusCode = 500;
362366
}
363367
// Format any encountered errors.
364-
if (result && result.errors) {
368+
if (result?.errors) {
365369
(result: any).errors = result.errors.map(formatErrorFn);
366370
}
367371

@@ -443,7 +447,8 @@ export type GraphQLParams = {|
443447
module.exports.getGraphQLParams = getGraphQLParams;
444448
async function getGraphQLParams(request: $Request): Promise<GraphQLParams> {
445449
const bodyData = await parseBody(request);
446-
const urlData = (request.url && url.parse(request.url, true).query) || {};
450+
const urlData =
451+
(request.url != null && url.parse(request.url, true).query) || {};
447452

448453
return parseGraphQLParams(urlData, bodyData);
449454
}

0 commit comments

Comments
 (0)