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: split AbstractConnectionResolver::get_args() and ::get_query_args() into ::prepare_*() methods #3124

Merged
merged 9 commits into from May 8, 2024

Conversation

justlevine
Copy link
Collaborator

@justlevine justlevine commented May 4, 2024

What does this implement/fix? Explain your changes.

This PR makes the following changes to AbstractConnectionResolver:

  • ::get_args() and ::get_query_args() now instantiate AbstractConnectionResolver::$args and ::$query_args only once.
  • Instead, the arg preparation logic has been moved into the new AbstractConnectionResolver::prepare_args() and ::prepare_query_args().
  • The usage of get_args() and get_query_args() have been replaced in the child resolvers with their ::prepare_() counterpart.

This improves the DX by reducing the amount of boilerplate needed when extending the AbstractConnectionResolver class, and improving lifecycle consistency, with potential performance benefits for child classes with complex args preparation logic.

There are no breaking changes in this PR.

Important

This PR requires #3123 which should be merged first.

The relevant diff for this PR can be seen at 77d99b9

Does this close any currently open issues?

Part of #2749

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

Any other comments?

  • AbstractConnectionResolver::$args and ::$query_args are still manually instantiated and their graphql_connection_* filters applied inside the class constructor to maintain b/c compatibility with classes that are currently overloading ::get_args() or ::get_query_args() directly.

Where has this been tested?

Operating System: Ubuntu 20.04 (wsl2 + devilbox + php8.1.15)

WordPress Version: 6.5.2

@justlevine justlevine changed the title dev: refactor AbstractConnectionResolver::get_args() to ::prepare_args() refactor: split AbstractConnectionResolver::get_args() to ::prepare_args() May 4, 2024
@justlevine justlevine changed the title refactor: split AbstractConnectionResolver::get_args() to ::prepare_args() refactor: split AbstractConnectionResolver::get_args() and ::get_query_args() into ::prepare() methods May 4, 2024
@justlevine justlevine changed the title refactor: split AbstractConnectionResolver::get_args() and ::get_query_args() into ::prepare() methods refactor: split AbstractConnectionResolver::get_args() and ::get_query_args() into ::prepare_*() methods May 4, 2024
@coveralls
Copy link

coveralls commented May 4, 2024

Coverage Status

coverage: 84.359% (+0.03%) from 84.33%
when pulling b4aad63 on justlevine:dev/refactor-get_args
into cb18964 on wp-graphql:develop.

Copy link

codeclimate bot commented May 4, 2024

Code Climate has analyzed commit b4aad63 and detected 12 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 12

View more on Code Climate.

@justlevine justlevine marked this pull request as ready for review May 4, 2024 12:04
@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 and removed Status: In Progress labels May 4, 2024
@justlevine
Copy link
Collaborator Author

Codeclimate issues are preexisting, just getting reflagged because the method names changed.

jasonbahl
jasonbahl previously approved these changes May 8, 2024
@jasonbahl jasonbahl merged commit 6c7cb70 into wp-graphql:develop May 8, 2024
29 of 30 checks passed
@justlevine justlevine deleted the dev/refactor-get_args branch May 8, 2024 17:37
@jasonbahl jasonbahl mentioned this pull request May 8, 2024
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

3 participants