Add strict paginated model data hook - #1680
Open
GiuseppeXD wants to merge 2 commits into
Open
Conversation
EXPLANATION: Added a direct `graphoid_load_paginated_data(scope, lookahead:)` model hook for generated pagination data and removed indirect `lookahead`/zero-argument `eager_load` dispatch through query objects. Added integration coverage for the strict hook, returned collections, unchanged no-hook pagination, and ignored legacy methods. Evaluated further N+1 architectures and retained the bounded first/second-hop API loader as the simplest query-efficient design. Verified both Mongo tester suites with 88 examples, 0 failures, and 7 existing pending examples each. --- PROMPT: great, since we are access to oxeanbits/graphoid implementation (and digitalize-api is the only consumer of this repo), search if an even more performance improvement could be done (address this n+1 solution in another query level, or another architeture to optimize memory and mongo finds). if we already achived a good point, lets target the simplest solution. portalize current PR solution into another PR (keep current one as it is), open a new branch in graphoid fork (and a PR), the new api PR could updated the submodule sha to the new-branch one (including several bumps already merged in master)
EXPLANATION: Split paginated data resolution into direct `graphoid_prepare_paginated_scope` and `graphoid_load_paginated_data` model stages, preserving the transformed scope between them. Added independent legacy `lookahead` and `eager_load` fallbacks for unmigrated models, plus integration coverage for direct hook sequencing and legacy lookahead behavior. Verified both Graphoid tester suites with 88 examples, 0 failures, and 7 existing pending examples each. --- PROMPT: ok agree with the architecture, lets update both api and graphoid prs
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.
Description ✍️
Adds two explicit model-class stages for generated pagination data:
Graphoid previously called
lookaheadandeager_loadonly through the resolved query object. With Mongoid criteria, application hooks depended onCriteria#method_missing; Mongoid 9.1 addingCriteria#eager_loadchanged dispatch and bypassed the model loader.The new stages call the captured model directly while retaining the former query-object methods as fallbacks for models that have not migrated.
Overview 🔍
flowchart LR A[Resolved pagination scope] --> B{Prepare model hook?} B -->|Yes| C[Prepare scope directly] B -->|No| D[Legacy scope.lookahead fallback] C --> E{Load model hook?} D --> E E -->|Yes| F[Load data directly] E -->|No| G[Legacy scope.eager_load fallback] F --> H[GraphQL serialization] G --> HResponsibilities
graphoid_prepare_paginated_scopegraphoid_load_paginated_datalookaheadfallbackeager_loadfallbackdatalookahead as a required keyword to direct hooks.scope.lookahead(scope, lookahead)contract as fallback.Checks ☑️
git diff --checkTest Guidance
ASDF_RUBY_VERSION=3.4.8 DRIVER=mongo bundle exec rspec spec/graphoid/queries/pagination_spec.rbfromspec/tester_mongo.spec/tester_mongo_rails_6for the alternate GraphQL dependency.lookahead, and confirm fallback behavior remains available.