Skip to content

Conversation

@justlevine
Copy link
Collaborator

What does this implement/fix? Explain your changes.

This PR refactors AbstractConnectionResolver::get_page_info() into an overloadable, protected ::prepare_page_info().
::get_page_info() will now call that (or child) method, apply the filter, and store it in a new AbstractConnectionResolver::$page_info property so future calls to the getter don't need to rebuild the array.

This both improves DX (smaller footprint, only need to overload the actual $page_info logic in children, consistent return value regardless of when it is called), and potentially increases performance (if ::get_page_info() is called multiple times in the lifecycle).

Does this close any currently open issues?

Part of #2749

Any relevant logs, error output, GraphiQL screenshots, etc?

Any other comments?

This PR is based on #3082 , which should be merged first.

Where has this been tested?

Operating System: Ubuntu 20.04 (wsl2 + devilbox + php 8.1.15)

WordPress Version: 6.4.3

@justlevine justlevine requested a review from jasonbahl March 30, 2024 13:25
@justlevine justlevine added type: enhancement Improvements to existing functionality status: in review Awaiting review before merging or closing needs: reviewer response This needs the attention of a codeowner or maintainer component: connections Relating to GraphQL Connections scope: api Issues related to access functions, actions, and filters labels Mar 30, 2024
@jasonbahl jasonbahl merged commit 0504a22 into chore/connection-resolvers-cleanup Apr 22, 2024
This was referenced Apr 22, 2024
@justlevine justlevine deleted the dev/prepare_page_info branch April 23, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: connections Relating to GraphQL Connections needs: reviewer response This needs the attention of a codeowner or maintainer scope: api Issues related to access functions, actions, and filters status: in review Awaiting review before merging or closing type: enhancement Improvements to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants