feat(graphql): Make gql query timeout optional #1473
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.
Problem
The latest version of the graphql package enforces a timeout on its queries.
Solution
Make the request timeout duration optional, and if omitted, will not invoke
timeout
on the query request stream.Why
We prefer to let our underlying http library (Dio) handle our timeouts, and as such decouple the responsibility from the gql client itself.
Not only does this let us define timeout logic in one place (the Dio config) and share it with non-gql requests, but it also vastly simplifies our unit testing story. We only mock our Dio client (and not the gql client itself), which effectively lets us build a testing story as close to production as possible. I couldn't for the life of me figure out how to adapt our unit tests to accommodate
.timeout
injected within the gql client itself. (The unit test failures were basically "a timer still exists" even though the requests have already finished.)The workaround before this PR
Because our unit testing uses the gql client itself (instead of mocking it), bumping to the latest beta version of this package started failing basically every unit test.
See: #1457
To get around this, we basically hijacked the pub cache to force a custom patch that removes
.timeout
entirely. We can remove this patch if this PR is merged.