Feature/#1738 introduce common interfaces#2022
Feature/#1738 introduce common interfaces#2022jasonbahl wants to merge 20 commits intowp-graphql:developfrom
Conversation
… not apply properly
…nterface - Remove fields from `Commenter` that are applied by the implemented Interfaces
- Register ConnectionInterface.php - Add `Node` and `DatabaseIdentifier` to `Commenter` Interface - Add `Node`, `UniformResourceIdentifiable` and `DatabaseIdentifier` Interfaces to `MenuItemLinkable` - add `revisions` connection to the RootQuery: BREAKING as this returns a connection to `ContentNode` instead of `ContentRevisionUnion` - add `revisions` connection to `User`: BREAKING as this returns a connection to `ContentNode` instead of `ContentRevisionUnion`
…common-interfaces # Conflicts: # src/Registry/TypeRegistry.php # src/Type/ObjectType/RootQuery.php # src/Type/ObjectType/User.php
- Add CommentConnectionInterface to the TypeRegistry - Add registration for CommentConnection Interface - Update ConnectionInterfaceTest to work with updated WPGraphQLTestCase
- Apply ContentNodeConnection interface to connections to ContentNodes - run composer fix-cs to update some spacing
- Apply ContentTypeConnection Interface to connections to ContentTypes
- Apply HierarchicalNode Interface on HierarchicalTermNode, HierarchicalContentNode and PostObject and TermObject types that are hierarchical.
- Apply `MenuItemConnection` to connections to MenuItems
- Apply TaxonomyConnection Interface to connections to Taxonomies
- Apply TermNodeConnection Interface to connections to TermNodes
- Apply UserConnection Interface to connections to the User type
- adjust how the query_class is passed through context - Add UserConnection Interface - Apply UserConnection Interface to connections to Users - Add new tests for registering connections - Add backward compatible test for PostObjectUnion - deprecate MenuItemObjectUnion - deprecate PostObjectUnion - deprecate TermObjectUnion
| 'queryClass' => 'WP_Query', | ||
| 'connectionArgs' => PostObjects::get_connection_args(), | ||
| 'resolve' => function ( $root, $args, $context, $info ) { | ||
| return DataSource::resolve_post_objects_connection( $root, $args, $context, $info, 'revision' ); |
There was a problem hiding this comment.
Avoid too many return statements within this method.
| 'fromFieldName' => 'menuItems', | ||
| 'toType' => 'MenuItem', | ||
| 'connectionInterfaces' => [ 'MenuItemConnection' ], | ||
| 'connectionArgs' => [ |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| 'Previewable', | ||
| [ | ||
| 'description' => __( 'Nodes that can be seen in a preview (unpublished) state.', 'wp-graphql' ), | ||
| 'fields' => [ |
There was a problem hiding this comment.
Similar blocks of code found in 3 locations. Consider refactoring.
| @@ -0,0 +1,46 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Similar blocks of code found in 10 locations. Consider refactoring.
| @@ -0,0 +1,46 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Similar blocks of code found in 10 locations. Consider refactoring.
| @@ -0,0 +1,46 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Similar blocks of code found in 10 locations. Consider refactoring.
| @@ -0,0 +1,46 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Similar blocks of code found in 10 locations. Consider refactoring.
| @@ -0,0 +1,46 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Similar blocks of code found in 10 locations. Consider refactoring.
| @@ -0,0 +1,46 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Similar blocks of code found in 10 locations. Consider refactoring.
| @@ -0,0 +1,46 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Similar blocks of code found in 10 locations. Consider refactoring.
|
Code Climate has analyzed commit db61369 and detected 16 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
… interface to be compatible with the upcoming WPGraphQL connection updates (wp-graphql/wp-graphql#2022)
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This issue has been automatically closed because it has not had recent activity. If you believe this issue is still valid, please open a new issue and mark this as a related issue. |
|
closing in favor of #2617 |
|
temp re-opening |
What does this implement/fix? Explain your changes.
This pull request introduces a number of new Interfaces and applies them throughout the Schema.
Interfaces introduced in this PR are:
CommentConnectionCommenterConnectionConnectionConnectionEdgeContentNodeConnectionContentTypeConnectionHierarchicalNodeMenuConnectionMenuItemConnectionMenuItemLinkableConnectionPreviewableTaxonomyConnectionTermNodeConnectionUserConnectionDoes this close any currently open issues?
closes #1738
Any other comments?
These connections add a lot of value to Schema organization, code reusability, and introspection.
One can now use GraphiQL to find all instances of Connections in the Schema like so:
One could also look for all Connections that implement a more specific Connection Interface, such as
ContentNodeConnection. This interface is applied to any node that has a connection to any type of Content Node. So a User to Post connection is aContentNodeConnectionand a User to Page connection is also a ContentNodeConnection.These shared connection interfaces allow client developers to have a better understanding of shared properties of connections and can allow for reduced code when querying similar data from the Graph.
On the server side, developers can more easily add features to specific connections or general connection interfaces.