diff --git a/src/execution/__tests__/executor-test.js b/src/execution/__tests__/executor-test.js index 4d2fdab48f..fa293df123 100644 --- a/src/execution/__tests__/executor-test.js +++ b/src/execution/__tests__/executor-test.js @@ -32,7 +32,7 @@ describe('Execute: Handles basic execution tasks', () => { }); // $DisableFlowOnNegativeTest - expect(() => execute({ schema })).to.throw('Must provide document'); + expect(() => execute({ schema })).to.throw('Must provide document.'); }); it('throws if no schema is provided', () => { diff --git a/src/execution/execute.js b/src/execution/execute.js index d13590d261..fe80d6c980 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -251,7 +251,7 @@ export function assertValidExecutionArguments( document: DocumentNode, rawVariableValues: ?{ +[variable: string]: mixed, ... }, ): void { - devAssert(document, 'Must provide document'); + devAssert(document, 'Must provide document.'); // If the schema used for execution is invalid, throw an error. assertValidSchema(schema); diff --git a/src/jsutils/invariant.js b/src/jsutils/invariant.js index a53db54a8e..b32e04a84f 100644 --- a/src/jsutils/invariant.js +++ b/src/jsutils/invariant.js @@ -4,7 +4,7 @@ export default function invariant(condition: mixed, message?: string): void { const booleanCondition = Boolean(condition); if (!booleanCondition) { throw new Error( - message != null ? message : 'Unexpected invariant triggered', + message != null ? message : 'Unexpected invariant triggered.', ); } } diff --git a/src/language/__tests__/parser-test.js b/src/language/__tests__/parser-test.js index 61dc49792d..a8b8bb9656 100644 --- a/src/language/__tests__/parser-test.js +++ b/src/language/__tests__/parser-test.js @@ -23,12 +23,12 @@ function expectSyntaxError(text) { describe('Parser', () => { it('asserts that a source to parse was provided', () => { // $DisableFlowOnNegativeTest - expect(() => parse()).to.throw('Must provide Source. Received: undefined'); + expect(() => parse()).to.throw('Must provide Source. Received: undefined.'); }); it('asserts that an invalid source to parse was provided', () => { // $DisableFlowOnNegativeTest - expect(() => parse({})).to.throw('Must provide Source. Received: {}'); + expect(() => parse({})).to.throw('Must provide Source. Received: {}.'); }); it('parse provides useful errors', () => { diff --git a/src/language/__tests__/printer-test.js b/src/language/__tests__/printer-test.js index 1df337b08c..aab7daa182 100644 --- a/src/language/__tests__/printer-test.js +++ b/src/language/__tests__/printer-test.js @@ -27,7 +27,7 @@ describe('Printer: Query document', () => { const badAST = { random: 'Data' }; // $DisableFlowOnNegativeTest expect(() => print(badAST)).to.throw( - 'Invalid AST Node: { random: "Data" }', + 'Invalid AST Node: { random: "Data" }.', ); }); diff --git a/src/language/__tests__/schema-printer-test.js b/src/language/__tests__/schema-printer-test.js index 3993f1bf6d..3862ff53db 100644 --- a/src/language/__tests__/schema-printer-test.js +++ b/src/language/__tests__/schema-printer-test.js @@ -23,7 +23,7 @@ describe('Printer: SDL document', () => { const badAST = { random: 'Data' }; // $DisableFlowOnNegativeTest expect(() => print(badAST)).to.throw( - 'Invalid AST Node: { random: "Data" }', + 'Invalid AST Node: { random: "Data" }.', ); }); diff --git a/src/language/parser.js b/src/language/parser.js index b877df7102..82e120ce2a 100644 --- a/src/language/parser.js +++ b/src/language/parser.js @@ -171,7 +171,7 @@ class Parser { const sourceObj = typeof source === 'string' ? new Source(source) : source; devAssert( sourceObj instanceof Source, - `Must provide Source. Received: ${inspect(sourceObj)}`, + `Must provide Source. Received: ${inspect(sourceObj)}.`, ); this._lexer = new Lexer(sourceObj); diff --git a/src/language/source.js b/src/language/source.js index 2e2127a377..68c117f648 100644 --- a/src/language/source.js +++ b/src/language/source.js @@ -27,11 +27,11 @@ export class Source { this.locationOffset = locationOffset || { line: 1, column: 1 }; devAssert( this.locationOffset.line > 0, - 'line in locationOffset is 1-indexed and must be positive', + 'line in locationOffset is 1-indexed and must be positive.', ); devAssert( this.locationOffset.column > 0, - 'column in locationOffset is 1-indexed and must be positive', + 'column in locationOffset is 1-indexed and must be positive.', ); } } diff --git a/src/language/visitor.js b/src/language/visitor.js index 9bccb1bc62..ef3d533fee 100644 --- a/src/language/visitor.js +++ b/src/language/visitor.js @@ -294,7 +294,7 @@ export function visit( let result; if (!Array.isArray(node)) { if (!isNode(node)) { - throw new Error('Invalid AST Node: ' + inspect(node)); + throw new Error(`Invalid AST Node: ${inspect(node)}.`); } const visitFn = getVisitFn(visitor, node.kind, isLeaving); if (visitFn) { diff --git a/src/subscription/__tests__/subscribe-test.js b/src/subscription/__tests__/subscribe-test.js index 94d7766cc3..a9952b3343 100644 --- a/src/subscription/__tests__/subscribe-test.js +++ b/src/subscription/__tests__/subscribe-test.js @@ -337,13 +337,13 @@ describe('Subscription Initialization Phase', () => { await expectPromiseToThrow( // $DisableFlowOnNegativeTest () => subscribe(emailSchema, null), - 'Must provide document', + 'Must provide document.', ); await expectPromiseToThrow( // $DisableFlowOnNegativeTest () => subscribe({ schema: emailSchema }), - 'Must provide document', + 'Must provide document.', ); }); @@ -386,7 +386,7 @@ describe('Subscription Initialization Phase', () => { await expectPromiseToThrow( () => createSubscription(pubsub, invalidEmailSchema), - 'Subscription field must return Async Iterable. Received: "test"', + 'Subscription field must return Async Iterable. Received: "test".', ); }); diff --git a/src/subscription/subscribe.js b/src/subscription/subscribe.js index 5252532675..ac90c3e1c5 100644 --- a/src/subscription/subscribe.js +++ b/src/subscription/subscribe.js @@ -283,9 +283,10 @@ export function createSourceEventStream( // Note: isAsyncIterable above ensures this will be correct. return ((eventStream: any): AsyncIterable); } + throw new Error( - 'Subscription field must return Async Iterable. Received: ' + - inspect(eventStream), + 'Subscription field must return Async Iterable. ' + + `Received: ${inspect(eventStream)}.`, ); }); } catch (error) { diff --git a/src/type/__tests__/definition-test.js b/src/type/__tests__/definition-test.js index 64e010d127..3d979ce2cd 100644 --- a/src/type/__tests__/definition-test.js +++ b/src/type/__tests__/definition-test.js @@ -303,7 +303,7 @@ describe('Type System: Objects', () => { }, }); expect(() => objType.getFields()).to.throw( - 'SomeObject.f field config must be an object', + 'SomeObject.f field config must be an object.', ); }); diff --git a/src/type/definition.js b/src/type/definition.js index 0970774d8e..e4d2542c2a 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -765,7 +765,7 @@ function defineFieldMap( return mapValue(fieldMap, (fieldConfig, fieldName) => { devAssert( isPlainObj(fieldConfig), - `${config.name}.${fieldName} field config must be an object`, + `${config.name}.${fieldName} field config must be an object.`, ); devAssert( !('isDeprecated' in fieldConfig), diff --git a/src/utilities/__tests__/assertValidName-test.js b/src/utilities/__tests__/assertValidName-test.js index c08b1f723b..8eb60dbd6d 100644 --- a/src/utilities/__tests__/assertValidName-test.js +++ b/src/utilities/__tests__/assertValidName-test.js @@ -14,7 +14,7 @@ describe('assertValidName()', () => { it('throws for non-strings', () => { // $DisableFlowOnNegativeTest - expect(() => assertValidName({})).to.throw(/Expected string/); + expect(() => assertValidName({})).to.throw('Expected name to be a string.'); }); it('throws for names with invalid characters', () => { diff --git a/src/utilities/__tests__/stripIgnoredCharacters-test.js b/src/utilities/__tests__/stripIgnoredCharacters-test.js index f410261e58..12c895a86c 100644 --- a/src/utilities/__tests__/stripIgnoredCharacters-test.js +++ b/src/utilities/__tests__/stripIgnoredCharacters-test.js @@ -109,14 +109,14 @@ describe('stripIgnoredCharacters', () => { it('asserts that a source was provided', () => { // $DisableFlowOnNegativeTest expect(() => stripIgnoredCharacters()).to.throw( - 'Must provide string or Source. Received: undefined', + 'Must provide string or Source. Received: undefined.', ); }); it('asserts that a valid source was provided', () => { // $DisableFlowOnNegativeTest expect(() => stripIgnoredCharacters({})).to.throw( - 'Must provide string or Source. Received: {}', + 'Must provide string or Source. Received: {}.', ); }); diff --git a/src/utilities/assertValidName.js b/src/utilities/assertValidName.js index 8622236dd2..032e798cf2 100644 --- a/src/utilities/assertValidName.js +++ b/src/utilities/assertValidName.js @@ -25,7 +25,7 @@ export function isValidNameError( name: string, node?: ASTNode | void, ): GraphQLError | void { - devAssert(typeof name === 'string', 'Expected string'); + devAssert(typeof name === 'string', 'Expected name to be a string.'); if (name.length > 1 && name[0] === '_' && name[1] === '_') { return new GraphQLError( `Name "${name}" must not begin with "__", which is reserved by GraphQL introspection.`, diff --git a/src/utilities/astFromValue.js b/src/utilities/astFromValue.js index e4972960a4..9bf8501175 100644 --- a/src/utilities/astFromValue.js +++ b/src/utilities/astFromValue.js @@ -138,7 +138,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode { }; } - throw new TypeError(`Cannot convert value to AST: ${inspect(serialized)}`); + throw new TypeError(`Cannot convert value to AST: ${inspect(serialized)}.`); } // Not reachable. All possible input types have been considered. diff --git a/src/utilities/buildASTSchema.js b/src/utilities/buildASTSchema.js index 4fbb763ffa..337efd125d 100644 --- a/src/utilities/buildASTSchema.js +++ b/src/utilities/buildASTSchema.js @@ -118,7 +118,7 @@ export function buildASTSchema( ): GraphQLSchema { devAssert( documentAST && documentAST.kind === Kind.DOCUMENT, - 'Must provide valid Document AST', + 'Must provide valid Document AST.', ); if (!options || !(options.assumeValid || options.assumeValidSDL)) { diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index 74383e74d2..d2391939f6 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -99,7 +99,7 @@ export function extendSchema( devAssert( documentAST && documentAST.kind === Kind.DOCUMENT, - 'Must provide valid Document AST', + 'Must provide valid Document AST.', ); if (!options || !(options.assumeValid || options.assumeValidSDL)) { @@ -211,7 +211,7 @@ export function extendSchema( function replaceDirectives( directives: $ReadOnlyArray, ): Array { - devAssert(directives, 'schema must have default directives'); + devAssert(directives, 'schema must have default directives.'); return directives.map(directive => { const config = directive.toConfig(); diff --git a/src/utilities/stripIgnoredCharacters.js b/src/utilities/stripIgnoredCharacters.js index e6ad305a1b..2b2036b109 100644 --- a/src/utilities/stripIgnoredCharacters.js +++ b/src/utilities/stripIgnoredCharacters.js @@ -66,7 +66,7 @@ export function stripIgnoredCharacters(source: string | Source): string { const sourceObj = typeof source === 'string' ? new Source(source) : source; if (!(sourceObj instanceof Source)) { throw new TypeError( - `Must provide string or Source. Received: ${inspect(sourceObj)}`, + `Must provide string or Source. Received: ${inspect(sourceObj)}.`, ); } diff --git a/src/validation/validate.js b/src/validation/validate.js index 2fb7b83896..6adc314d1c 100644 --- a/src/validation/validate.js +++ b/src/validation/validate.js @@ -43,7 +43,7 @@ export function validate( typeInfo?: TypeInfo = new TypeInfo(schema), options?: {| maxErrors?: number |} = { maxErrors: undefined }, ): $ReadOnlyArray { - devAssert(documentAST, 'Must provide document'); + devAssert(documentAST, 'Must provide document.'); // If the schema used for validation is invalid, throw an error. assertValidSchema(schema);