-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better handling of syntax errors encountered while generating the per…
…sisted query manifest (#345)
- Loading branch information
1 parent
2f96b1e
commit 145836c
Showing
4 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@apollo/generate-persisted-query-manifest": patch | ||
--- | ||
|
||
Better error reporting when an error is raised while parsing a source file for GraphQL query strings (such as a syntax error). Previously the stack trace was reported to the console with little to no identifying information as to which file caused the error. The filename is now reported similarly to other errors encountered when running the CLI. An additional improvement is that it will now gather all errors, including syntax errors in a single pass so that syntax errors do not halt the program in place. |
28 changes: 28 additions & 0 deletions
28
packages/generate-persisted-query-manifest/src/@types/lib.es5.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Fixes https://github.com/microsoft/TypeScript/issues/16655 for `Array.prototype.filter()` | ||
* For example, using the fix the type of `bar` is `string[]` in the below snippet as it should be. | ||
* | ||
* const foo: (string | null | undefined)[] = []; | ||
* const bar = foo.filter(Boolean); | ||
* | ||
* For related definitions, see https://github.com/microsoft/TypeScript/blob/master/src/lib/es5.d.ts | ||
* | ||
* Original licenses apply, see | ||
* - https://github.com/microsoft/TypeScript/blob/master/LICENSE.txt | ||
* - https://stackoverflow.com/help/licensing | ||
*/ | ||
|
||
/** See https://stackoverflow.com/a/51390763/1470607 */ | ||
type Falsy = false | 0 | "" | null | undefined; | ||
|
||
interface Array<T> { | ||
/** | ||
* Returns the elements of an array that meet the condition specified in a callback function. | ||
* @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. | ||
* @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. | ||
*/ | ||
filter<S extends T>( | ||
predicate: BooleanConstructor, | ||
thisArg?: any, | ||
): Exclude<S, Falsy>[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters