Skip to content

Conversation

@justlevine
Copy link
Collaborator

What does this implement/fix? Explain your changes.

This PR refactors the way AbstractConnectionResolver handles DataLoaders. More specifically:

  • Child classes now define their loader names in ::loader_name()
  • ::get_loader_name() is no longer an abstract method, and instead calls ::loader_name() if it has not already been set as a class property.
  • Added a new graphql_connection_loader_name filter to more easily apply custom data loaders to an existing Connection Resolver (e.g. CPT-specific).
  • The AbstractConnectionResolver::$loader property now only gets instantiated once, no matter how many times ::get_loader() is called. As a result, all direct calls to ::$loader have been replaced with ::get_loader().
  • The overloaded ::get_loader_name() methods in the child classes have been replaced with ::loader_name().

There are no breaking changes in this PR.

Does this close any currently open issues?

Part of #2749

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

Any other comments?

Where has this been tested?

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

WordPress Version: 6.4.3

@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
@justlevine justlevine requested a review from jasonbahl March 30, 2024 18:32
@jasonbahl jasonbahl merged commit 41909cb into dev/cr2-backport/deprecate-camelcased Apr 22, 2024
This was referenced Apr 22, 2024
@justlevine justlevine deleted the dev/cr2-backport/loader-handling branch April 23, 2024 20:00
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