Skip to content

Feature/#1738 introduce common interfaces#2022

Closed
jasonbahl wants to merge 20 commits intowp-graphql:developfrom
jasonbahl:feature/#1738-introduce-common-interfaces
Closed

Feature/#1738 introduce common interfaces#2022
jasonbahl wants to merge 20 commits intowp-graphql:developfrom
jasonbahl:feature/#1738-introduce-common-interfaces

Conversation

@jasonbahl
Copy link
Copy Markdown
Collaborator

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:

  • CommentConnection
  • CommenterConnection
  • Connection
  • ConnectionEdge
  • ContentNodeConnection
  • ContentTypeConnection
  • HierarchicalNode
  • MenuConnection
  • MenuItemConnection
  • MenuItemLinkableConnection
  • Previewable
  • TaxonomyConnection
  • TermNodeConnection
  • UserConnection

Does 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:

connection-interface-implementations

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 a ContentNodeConnection and a User to Page connection is also a ContentNodeConnection.

content-node-connection-implementations

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.

jasonbahl added 18 commits July 20, 2021 07:54
…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
@jasonbahl jasonbahl added component: architecture Relating to fundamental architectural decisions component: connections Relating to GraphQL Connections component: interfaces Relating to GraphQL Interface Types scope: api Issues related to access functions, actions, and filters component: query Relating to GraphQL Queries scope: code quality Refactoring, linting, and enforcing coding standards labels Jul 20, 2021
@jasonbahl jasonbahl self-assigned this Jul 20, 2021
'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' );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid too many return statements within this method.

'fromFieldName' => 'menuItems',
'toType' => 'MenuItem',
'connectionInterfaces' => [ 'MenuItemConnection' ],
'connectionArgs' => [
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' => [
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

@@ -0,0 +1,46 @@
<?php
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 10 locations. Consider refactoring.

@@ -0,0 +1,46 @@
<?php
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 10 locations. Consider refactoring.

@coveralls
Copy link
Copy Markdown

coveralls commented Jul 20, 2021

Coverage Status

Coverage increased (+0.2%) to 79.614% when pulling db61369 on jasonbahl:feature/#1738-introduce-common-interfaces into bef1d49 on wp-graphql:develop.

@@ -0,0 +1,46 @@
<?php
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 10 locations. Consider refactoring.

@@ -0,0 +1,46 @@
<?php
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 10 locations. Consider refactoring.

@@ -0,0 +1,46 @@
<?php
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 10 locations. Consider refactoring.

@@ -0,0 +1,46 @@
<?php
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 10 locations. Consider refactoring.

@@ -0,0 +1,46 @@
<?php
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 10 locations. Consider refactoring.

@qlty-cloud-legacy
Copy link
Copy Markdown

Code Climate has analyzed commit db61369 and detected 16 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Duplication 14

View more on Code Climate.

jasonbahl added a commit to jasonbahl/wp-graphql-woocommerce that referenced this pull request Dec 10, 2021
… interface to be compatible with the upcoming WPGraphQL connection updates (wp-graphql/wp-graphql#2022)
@stale
Copy link
Copy Markdown

stale bot commented Aug 2, 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.

@stale stale bot added the stale label Aug 2, 2022
@stale
Copy link
Copy Markdown

stale bot commented Sep 1, 2022

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.

@stale stale bot closed this Sep 1, 2022
@justlevine justlevine reopened this Sep 2, 2022
@stale stale bot removed the stale label Sep 2, 2022
@jasonbahl jasonbahl mentioned this pull request Nov 22, 2022
17 tasks
@jasonbahl
Copy link
Copy Markdown
Collaborator Author

closing in favor of #2617

@jasonbahl jasonbahl closed this Nov 22, 2022
@jasonbahl
Copy link
Copy Markdown
Collaborator Author

temp re-opening

@jasonbahl jasonbahl reopened this Nov 22, 2022
@jasonbahl jasonbahl closed this Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: architecture Relating to fundamental architectural decisions component: connections Relating to GraphQL Connections component: interfaces Relating to GraphQL Interface Types component: query Relating to GraphQL Queries scope: api Issues related to access functions, actions, and filters scope: code quality Refactoring, linting, and enforcing coding standards

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Common Interfaces that other Interfaces can Implement

4 participants