Commit dcbbc34
authored
Invoke
* tests: Assert `didEncounterErrors` is invoked for execution errors.
Previously a missing test.
* tests: Assert error conditions for existing APQ logic (prior to improvements).
Previously, a number of APQ errors did not have tests for errors which could
arise at runtime. These include:
- When the APQ `version` is not a version that we support. (Currently, the
only supported `version` is `1`.
- When the APQ `version` is entirely omitted. (It must be `1`.)
- When the provided APQ `sha256Hash` doesn't match the provided `query`
during APQ registration.
I'm adding these tests which assert the existing logic without making any
changes to the logic itself prior to making a number of changes to said
logic which will ensure that these (again, existing) errors are _also_
propagated to the `didEncounterErrors` hook (They currently are NOT!).
* Invoke `didEncounterErrors` for errors during pre-parse phases.
Roughly, these "pre-parse" errors come in two forms: When the query
was entirely omitted, or APQ (automated persisted query) errors.
Arguably, there is a third form of pre-parse errors, but it would be
unexpected and potentially out of scope of the `didEncounterErrors`
life-cycle hook. Such an error would still be caught by `runHttpQuery.ts`,
but we wouldn't have a guarantee that our plugins have been initialized.
This is unlikely to improve until we re-work the entirety of the request
pipeline in Apollo Server 3.x.
While these errors were in-fact causing errors at runtime that were being
delivered to the client, those errors were not being delivered to the
plugin's `didEncounterErrors` hooks, causing reduced visibility by reporting
tools which utilize that life-cycle hook.
This commit changes the parent class of `InvaidGraphQLRequestError` from
`Error` to `GraphQLError` in order to allow such an error to be received by
`didEncounterErrors`, which requires `GraphQLError`s. The `GraphQLError`
itself is still an `instanceof Error`, so any existing code that leverages
such a condition should still work as expected, and I suspect that most
other conditions that could be checked on either an `Error` or
`GraphQLError` should also still remain the same. Despite any uncertain
here, I'd call this a net-win for reporting errors more reliably to the hook
on which they're expected to be received.
* Add CHANGELOG.md for #3614.didEncounterErrors for known errors during pre-parse. (#3614)1 parent 4c41e80 commit dcbbc34
5 files changed
Lines changed: 252 additions & 32 deletions
File tree
- packages
- apollo-server-core/src
- __tests__
- apollo-server-integration-testsuite/src
- apollo-server-types/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 31 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
517 | 525 | | |
518 | 526 | | |
519 | 527 | | |
520 | 528 | | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
| 529 | + | |
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
540 | 561 | | |
541 | 562 | | |
542 | 563 | | |
543 | 564 | | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
| 565 | + | |
553 | 566 | | |
554 | 567 | | |
555 | 568 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | | - | |
141 | | - | |
142 | | - | |
| 140 | + | |
| 141 | + | |
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
| |||
164 | 163 | | |
165 | 164 | | |
166 | 165 | | |
167 | | - | |
| 166 | + | |
168 | 167 | | |
169 | 168 | | |
170 | 169 | | |
171 | 170 | | |
172 | 171 | | |
173 | | - | |
174 | | - | |
175 | | - | |
| 172 | + | |
| 173 | + | |
176 | 174 | | |
177 | 175 | | |
178 | 176 | | |
| |||
186 | 184 | | |
187 | 185 | | |
188 | 186 | | |
189 | | - | |
| 187 | + | |
| 188 | + | |
190 | 189 | | |
191 | 190 | | |
192 | 191 | | |
| |||
313 | 312 | | |
314 | 313 | | |
315 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
316 | 323 | | |
317 | 324 | | |
318 | 325 | | |
| |||
493 | 500 | | |
494 | 501 | | |
495 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
496 | 523 | | |
497 | 524 | | |
498 | 525 | | |
| |||
0 commit comments