Add didEncounterErrors to request pipeline API.#2719
Merged
abernix merged 1 commit intoMay 24, 2019
Conversation
(As I mentioned at the bottom of #2714) This adds a new life-cycle event to the new request pipeline API called `didEncounterErrors`, which receives `requestContext`'s **unformatted** `errors`. (The `requestContext` represents an individual request within Apollo Server.) These `errors` give access to potentially different `errors` than those received within `response.errors`, which are sent to the client and available on the `willSendResponse` life-cycle hook, since they are **not** passed through the `formatError` transformation. This can allow plugin implementers to take advantage of the actual errors and properties which may be pruned from the error before transmission to the client. While most other request pipeline life-cycle events provide a guarantee of their arguments, this `didEncounterErrors` will have a little bit less certainty since the errors could have happened in parsing, validation, or execution, and thus different contracts would have been made (e.g. we may not have been able to negotiate a `requestContext.document` if we could not parse the operation). This still needs tests and I suspect I'll have some additional changes prior to this becoming official, but it can ship as-is for now and will live in the Apollo Server 2.6.0 alpha for the time-being. Use with minimal risk, but with the caveat that the final API may change. Also, I'll need to add docs to #2008.
abernix
added a commit
that referenced
this pull request
May 24, 2019
abernix
added a commit
that referenced
this pull request
May 27, 2019
This accounts for some preliminary tests for things which don't already have tests, but was primarily motivated by the new `didEncounterErrors` life-cycle hooks that I introduced in #2719.
abernix
added a commit
that referenced
this pull request
May 27, 2019
abernix
added a commit
that referenced
this pull request
May 27, 2019
This accounts for some preliminary tests for things which don't already have tests, but was primarily motivated by the new `didEncounterErrors` life-cycle hooks that I introduced in #2719.
abernix
added a commit
that referenced
this pull request
May 27, 2019
4 tasks
abernix
added a commit
that referenced
this pull request
Jun 30, 2019
This was referenced Jul 8, 2019
This was referenced Jul 27, 2019
Closed
Contributor
|
For anyone looking for more info on which includes:
|
Member
Author
|
And just to clarify |
StephenBarlow
pushed a commit
that referenced
this pull request
Aug 23, 2019
This was referenced Aug 26, 2019
StephenBarlow
pushed a commit
that referenced
this pull request
Aug 28, 2019
StephenBarlow
pushed a commit
that referenced
this pull request
Sep 13, 2019
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(As I mentioned at the bottom of #2714)
This adds a new life-cycle event to the new request pipeline API called
didEncounterErrors, which receivesrequestContext's unformattederrors. (TherequestContextrepresents an individual request within Apollo Server.) Theseerrorsgive access to potentially differenterrorsthan those received withinresponse.errors, which are sent to the client and available on thewillSendResponselife-cycle hook, since they are not passed through theformatErrortransformation. This can allow plugin implementers to take advantage of the actual errors and properties which may be pruned from the error before transmission to the client.While most other request pipeline life-cycle events provide a guarantee of their arguments, this
didEncounterErrorswill have a little bit less certainty since the errors could have happened in parsing, validation, or execution, and thus different contracts would have been made (e.g. we may not have been able to negotiate arequestContext.documentif we could not parse the operation).This should hopefully be a step in the right direction for desires like those expressed in #1709, and helps make that more of a reality when combined with the recent #2714.
This still needs tests and(Edit: Tests are now included in 705defb) I suspect I'll have some additional changes prior to this becoming official, but it can ship as-is for now and will live in the Apollo Server 2.6.0 alpha for the time-being. Use with minimal risk, but with the caveat that the final API may change. Also, I'll need to add docs to #2008 before we finally ship this.