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

Make few check more explicit #609

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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