chore: refactor AbstractConnectionResolver::$args handling#2521
Conversation
|
Code Climate has analyzed commit 128e7c3 and detected 0 issues on this pull request. View more on Code Climate. |
| * | ||
| * @since @todo | ||
| */ | ||
| $this->args = apply_filters( 'graphql_connection_args', $this->get_args(), $this ); |
There was a problem hiding this comment.
I think I'm ok with this filter being added, but it might be a bit naiive as it only targets connections, and not any type of field.
I was thinking it would make sense to allow filtering args on any field, not just connections.
Like described here: #965 (comment)
I think it would be nice to be able to filter args before they're used in resolution, but also do something with the args after resolution but before the response is returned.
Anyway, I think we can approach the bigger picture separately. This works for connections and has immediate benefits for working with connections.
| * | ||
| * Deprecated in favor of $this->get_args(); | ||
| * | ||
| * @deprecated @todo |
There was a problem hiding this comment.
We can update the deprecated version/message when release is prepped. 👍🏻
What does this implement/fix? Explain your changes.
This PR deprecates the
AbstractConnectionResolver::getArgs()in favor ofAbstractConnectionResolver::get_args(), which is passed through thegraphql_connection_argsWP filter on instantiation.This PR replaces part of #2340 , and lays the foundation to create the individual PRs necessary to close #998 in a piecemeal approach, by allowing child
ConnectionResolverclasses and 3rd-party code to manipulate connection arg values. before they are used in the resolver.Does this close any currently open issues?
…
Any relevant logs, error output, GraphiQL screenshots, etc?
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
Any other comments?
Where has this been tested?
Operating System: Ubuntu 20.04 (wsl2 + devilbox + php 8.0.19)
WordPress Version: 6.0.2