[go: up one dir, main page]

Skip to content

GraphQL: LooksAhead - Allow scoping of eagerly loaded associations

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

About

This issue was created from the discussion in !40555 (comment 406896411).

GitLab's GraphQL uses "lookahead" in resolvers that include LooksAhead to apply eager loading based on the fields in a query when fetching a record.

!40555 (merged) introduced a currentUserTodos field on a number of types, but we can't use LooksAhead out of the box because we need to apply scoping to the eagerly loaded association query.

Proposal

As suggested in !40555 (comment 406896411):

To deal with this, we probably need to add our own lookahead on current_user_todos, which stores the preloaded data on the query context.

We want to look at having a field prepend scoping into the eager loading on an object.

Testing

  • Unit tests to verify that the results are correct, request tests that verify that we get the expected performance benefit
  • Test for N+1 queries
Edited by 🤖 GitLab Bot 🤖