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

Add API tests #204

Closed
jaydenseric opened this issue Jul 15, 2020 · 2 comments
Closed

Add API tests #204

jaydenseric opened this issue Jul 15, 2020 · 2 comments

Comments

@jaydenseric
Copy link
Owner

At the moment there are pretty good linting and size limit tests, but no tests of the actual API.

I've already gotten started on them, but it will take another day or two of work to get 100% code coverage.

@jaydenseric jaydenseric changed the title Test the API Add API tests Jul 15, 2020
@jaydenseric
Copy link
Owner Author

OK, so I got stuck for half a day trying to figure out why abort controller and signal tests wouldn't work. Using our link, or the default HttpLink, the queries would get stuck and never resolve when aborted via a signal in fetchOptions. Turns out, Apollo Client is known to not support aborting queries via standard fetch and AbortControler signals. You have to use the Apollo Client subscription system ☹️

apollographql/apollo-client#4150

@jaydenseric
Copy link
Owner Author

It's pretty frustrating. Why does Apollo HttpLink have fetchOptions, but no documentation that under no circumstances should the standard signal fetch option be used:

https://www.apollographql.com/docs/link/links/http/#options

Furthermore, why does the HttpLink code defer to a user configured signal if it is in conflict with the way Apollo Client works?

https://github.com/apollographql/apollo-client/blob/3c56a1d7a696ed63b2d3681aab0c23b8ea0831db/src/link/http/createHttpLink.ts#L89

If the user supplies a signal that aborts the fetch, a return is used that causes the observable to never progress:

https://github.com/apollographql/apollo-client/blob/3c56a1d7a696ed63b2d3681aab0c23b8ea0831db/src/link/http/createHttpLink.ts#L134-L135

In that situation, if you did await apolloClient.query( it would never resolve; Node.js detects the Promise is stuck in a pending status and skips the rest of your code without an error.

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

No branches or pull requests

1 participant