diff --git a/.flowconfig b/.flowconfig index 0aafcc683b..fa9472bb98 100644 --- a/.flowconfig +++ b/.flowconfig @@ -11,7 +11,7 @@ [lints] sketchy-null-bool=off -sketchy-null-string=off +sketchy-null-string=error sketchy-null-number=error sketchy-null-mixed=error sketchy-number=error diff --git a/src/jsutils/invariant.js b/src/jsutils/invariant.js index d82cd87a19..a53db54a8e 100644 --- a/src/jsutils/invariant.js +++ b/src/jsutils/invariant.js @@ -3,6 +3,8 @@ export default function invariant(condition: mixed, message?: string): void { const booleanCondition = Boolean(condition); if (!booleanCondition) { - throw new Error(message || 'Unexpected invariant triggered'); + throw new Error( + message != null ? message : 'Unexpected invariant triggered', + ); } } diff --git a/src/language/source.js b/src/language/source.js index b7c31ef464..2e2127a377 100644 --- a/src/language/source.js +++ b/src/language/source.js @@ -23,7 +23,7 @@ export class Source { constructor(body: string, name?: string, locationOffset?: Location): void { this.body = body; - this.name = name || 'GraphQL request'; + this.name = name != null ? name : 'GraphQL request'; this.locationOffset = locationOffset || { line: 1, column: 1 }; devAssert( this.locationOffset.line > 0, diff --git a/src/utilities/buildClientSchema.js b/src/utilities/buildClientSchema.js index 366da69625..0ccccbb59d 100644 --- a/src/utilities/buildClientSchema.js +++ b/src/utilities/buildClientSchema.js @@ -350,9 +350,10 @@ export function buildClientSchema( function buildInputValue(inputValueIntrospection) { const type = getInputType(inputValueIntrospection.type); - const defaultValue = inputValueIntrospection.defaultValue - ? valueFromAST(parseValue(inputValueIntrospection.defaultValue), type) - : undefined; + const defaultValue = + inputValueIntrospection.defaultValue != null + ? valueFromAST(parseValue(inputValueIntrospection.defaultValue), type) + : undefined; return { description: inputValueIntrospection.description, type, diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index 35bc1067ad..f803c8437c 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -222,7 +222,7 @@ export function extendSchema( } function getMaybeTypeByName(typeName: ?string): ?GraphQLNamedType { - return typeName ? typeMap[typeName] : null; + return typeName != null ? typeMap[typeName] : null; } function getMergedDirectives(): Array { diff --git a/src/utilities/findDeprecatedUsages.js b/src/utilities/findDeprecatedUsages.js index 694937ff58..120680d132 100644 --- a/src/utilities/findDeprecatedUsages.js +++ b/src/utilities/findDeprecatedUsages.js @@ -34,7 +34,7 @@ export function findDeprecatedUsages( errors.push( new GraphQLError( `The field "${parentType.name}.${fieldDef.name}" is deprecated.` + - (reason ? ' ' + reason : ''), + (reason != null ? ' ' + reason : ''), node, ), ); @@ -50,7 +50,7 @@ export function findDeprecatedUsages( errors.push( new GraphQLError( `The enum value "${type.name}.${enumVal.name}" is deprecated.` + - (reason ? ' ' + reason : ''), + (reason != null && reason !== '' ? ' ' + reason : ''), node, ), ); diff --git a/src/utilities/getOperationAST.js b/src/utilities/getOperationAST.js index 5cb9986eb3..6b34b6dcea 100644 --- a/src/utilities/getOperationAST.js +++ b/src/utilities/getOperationAST.js @@ -18,7 +18,7 @@ export function getOperationAST( let operation = null; for (const definition of documentAST.definitions) { if (definition.kind === Kind.OPERATION_DEFINITION) { - if (!operationName) { + if (operationName == null) { // If no operation name was provided, only return an Operation if there // is one defined in the document. Upon encountering the second, return // null.