Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.14.0: apollo-server-testing createTestingClient broken #4170

Closed
6 tasks
Tallyb opened this issue May 27, 2020 · 4 comments
Closed
6 tasks

2.14.0: apollo-server-testing createTestingClient broken #4170

Tallyb opened this issue May 27, 2020 · 4 comments
Assignees
Labels

Comments

@Tallyb
Copy link
Contributor

Tallyb commented May 27, 2020

I am sorry for not deep diving into this any further, but this is more of a pre warning (as the version was released few hours ago).

Running tests with apollo-server and apollo-server-testing at 2.14 results this error:

TypeError: Cannot redefine property: Symbol(apolloServerExecutionDispatcherWillResolveField)
at Function.defineProperty ()

  at Object.<anonymous> (../../node_modules/apollo-server-core/src/requestPipeline.ts:431:14)
  at fulfilled (../../node_modules/apollo-server-core/dist/requestPipeline.js:5:58)

Downgrading to 2.13.1 restores to working.

This bug report should include:

  • A short, but descriptive title. The title doesn't need "Apollo" in it.
  • The package name and version of Apollo showing the problem.
  • If applicable, the last version of Apollo where the problem did not occur.
  • The expected behavior.
  • The actual behavior.
  • A simple, runnable reproduction!
    Please make a GitHub repository that anyone can clone and run and see the
    problem. Other great ways to demonstrate a reproduction are using our
    CodeSandbox template (https://codesandbox.io/s/apollo-server), or re-mixing
    our Glitch template (https://glitch.com/~apollo-launchpad).
    -->
@pdemarino
Copy link

I've noticed exactly the same issue.

@abernix
Copy link
Member

abernix commented May 28, 2020

Thanks for reporting this!

@pdemarino Can you put together a minimal reproduction? Figured it out. Reproductions are huge time savers though!

@abernix abernix added 🥀 needs-reproduction Lacks a runnable reproduction which can be used to quickly demonstrate a bug. 🛸 needs-more-information This is at risk of being closed if sufficient details can't be provided. 🪲 bug labels May 28, 2020
@abernix abernix self-assigned this May 28, 2020
@abernix abernix removed 🥀 needs-reproduction Lacks a runnable reproduction which can be used to quickly demonstrate a bug. 🛸 needs-more-information This is at risk of being closed if sufficient details can't be provided. labels May 28, 2020
@abernix abernix added this to the Release 2.14.1 milestone May 28, 2020
abernix added a commit that referenced this issue May 28, 2020
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
@abernix abernix changed the title apollo-server 2.14.0 is breaking tests 2.14.0: apollo-server-testing createTestingClient broken May 28, 2020
@abernix
Copy link
Member

abernix commented May 28, 2020

Hopefully fixed in 2.14.1 via 79c0025. Please report back if it's still problematic!

@Tallyb
Copy link
Contributor Author

Tallyb commented May 29, 2020

@abernix - I can confirm it works for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants