Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add AbstractConnectionResolver::prepare_page_info()and only instantiate once #3085

Merged
merged 1 commit into from Apr 22, 2024

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 added Type: Enhancement New feature or request Status: In Review Needs to be reviewed by a project maintainer before merge Needs: Reviewer Response This needs the attention of a codeowner or maintainer. Component: Connections Issues related to 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
2 checks passed
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 Issues related to 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 Needs to be reviewed by a project maintainer before merge Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants