-
Notifications
You must be signed in to change notification settings - Fork 468
Add post type / taxonomy args for defining the GraphQL model #2466
Copy link
Copy link
Open
Labels
needs: discussionRequires a discussion to proceedRequires a discussion to proceedscope: apiIssues related to access functions, actions, and filtersIssues related to access functions, actions, and filterstype: enhancementImprovements to existing functionalityImprovements to existing functionality
Description
What problem does this address?
There are numerous cases where a custom post type / taxonomy needs to use a custom model. Currently implementing a custom model is a complicated and imperfect process, as the model is usually hard-coded into the data loader and connection resolver. This requires devs to extend/replace those classes in addition to all the resolve callbacks that use them.
What is your proposed solution?
Continuing the work done in #2399 , a custom property should be added to WP_Post_Type and WP_Taxonomy that allows a user to set a custom model.
This model should then be used by the various DataLoader/ConnectionResolvers, falling back to the defaults when none is set.
What alternatives have you considered?
No response
Additional Context
- The plugin should dogfood this approach with
nav_menu(taxonomy) andnav_menu_items(post_type). - Assumption: If done correctly, there should be rarely (if ever) need to be a reason to create a custom DataLoader for a CPT/Tax term, as they mostly exist to work around the hardcoded
Modelinstantiation in core. This is premised on my own experience, as well as browsing the source code of WooGraphQLand WPGraphQL for BP. @kidunot89 , @renatonascalves if I'm missing a use case, please chime in 🙏 - The same assumption cannot be made about Connection Resolvers. Maybe in the future (after Common Interfaces that other Interfaces can Implement #1738, Registered Connections should apply an Interface to the "from" Type signifying it has said connection #2027) we can use the connection interface to determine what the resolver does with query args, but for now we probably need a separate WP_Post_Type / WP_Taxonomy parameter to supply a custom Resolver class so users dont need to filter every possible resolve callback to avoid issues like Wpgraphql resover for WoGraphql missing #2447
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
needs: discussionRequires a discussion to proceedRequires a discussion to proceedscope: apiIssues related to access functions, actions, and filtersIssues related to access functions, actions, and filterstype: enhancementImprovements to existing functionalityImprovements to existing functionality
Type
Projects
Status
💬 In Discussion