-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server-testing: Ensure user-provided context objects are cloned.
The `apollo-server-testing` package uses an internal Apollo Server method called `executeOperation` (introduced in [#1909]) in order to power its `createTestClient` functionality. This is the testing practice which is documented within [Integration testing] in the Apollo Server documentation. However, it failed to introduce the same context-cloning which [takes place in `runHttpQuery`][Ref 1], prior to arriving at the main request pipeline. Since the context was not cloned, and we had made the expectation in [#3988] that it was a unique context on every single request (which it was, in a non-testing context), the Symbol we use to implement `willResolveField` was already present [on the request pipeline][Ref 2] when running a subsequent test via `createTestClient`! This commit introduces the same cloning that takes place in `buildRequestContext` within `runHttpQuery`, and adds tests to ensure the behavior is preserved. [Fixes #4170]: #4170 [#1909]: #1909 [Integration testing]: https://www.apollographql.com/docs/apollo-server/testing/testing/ [Ref 1]: https://git.io/Jfou6 [#3988]: #3988 [Ref 2]: https://git.io/Jfouy
- Loading branch information
Showing
4 changed files
with
131 additions
and
28 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
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
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