Repository navigation
Conversation
…ock engages RelationConnection#async_dataloader? read `context[:dataloader]`, but Multiplex stores the dataloader on the multiplex context, not on the query context a connection holds, so the key is nil for schemas that `use GraphQL::Dataloader::AsyncDataloader` and the locks added in rmosolgo#5708 and rmosolgo#5717 never engaged. Read it through Query::Context#dataloader instead, which falls back to the multiplex dataloader, and build the Fiber specs' connections from a real query context so they exercise the same path execution does.
When a forward page (`first:`, no `last`/`before`) selects `hasNextPage` and also loads the page (`nodes`, `edges`, `startCursor` or `endCursor`), load `first + 1` rows and answer `hasNextPage` from whether the extra row came back, instead of running a second LIMIT query. Pages without `hasNextPage`, and `hasNextPage`-only queries, run exactly what they did before. ConnectionExtension now asks for the `:lookahead` extra and hands it to the connection, under both the legacy interpreter and Execution::Next. The extra is kept out of `connection.arguments`.
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #5773.
Problem
When a query selects both the page and pageInfo { hasNextPage }, RelationConnection runs two queries. One loads the page and the other checks for a row past it. The spec already notes this: "A better implementation would load first + 1 nodes and use that to set has_next_page."
Change
When hasNextPage is selected and the page is loaded anyway (nodes, edges, startCursor or endCursor), the connection loads first + 1 rows. It returns first of them and sets has_next_page from whether the extra row exists. That's one query instead of two.
This follows the lookahead approach suggested in #4908 :
What doesn't change
Cost
Every connection field now builds a Lookahead when it resolves (a few small objects), and :lookahead shows up in field.extras.