Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Connections need to connect to Types that implement the Node interface #675

Merged
merged 15 commits into from
Dec 7, 2022

Conversation

jasonbahl
Copy link
Collaborator

@jasonbahl jasonbahl commented Nov 30, 2022

What does this implement/fix? Explain your changes.

This PR Implements the "Node" interface on any Type that is used as a toType in a connection, as Connections need to connect to Node types

This PR implements the Node interface on these types, but does not handle the resolution of the ID field on each type, nor the resolution of a node( id: $id ) { ... } query

My goal is to unblock users, and we can finesse some of those details as follow-up PRs

Does this close any currently open issues?

closes #673

- move id resolver from product-attribute interface to the specific types
- update test to check for falsy vs null
@jasonbahl
Copy link
Collaborator Author

@kidunot89 this is pretty close.

There's still a broken test related to filters on the Product post type.

We need to figure out a different filter(s) for these filters: https://github.com/wp-graphql/wp-graphql-woocommerce/blob/develop/includes/class-core-schema-filters.php#L91-L117

@kidunot89 kidunot89 self-requested a review December 6, 2022 13:47
@@ -23,6 +23,7 @@ public static function register_interface( &$type_registry ) {
'Attribute',
[
'description' => __( 'Attribute object', 'wp-graphql-woocommerce' ),
'interfaces' => [ 'Node' ],
Copy link

Choose a reason for hiding this comment

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

Spaces must be used to indent lines; tabs are not allowed

@@ -23,6 +23,7 @@ public static function register_interface( &$type_registry ) {
'ProductAttribute',
[
'description' => __( 'Product attribute object', 'wp-graphql-woocommerce' ),
'interfaces' => [ 'Node' ],
Copy link

Choose a reason for hiding this comment

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

Spaces must be used to indent lines; tabs are not allowed

},
]
);
public static function register_interface() {
Copy link

Choose a reason for hiding this comment

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

Spaces must be used to indent lines; tabs are not allowed

},
]
);
public static function register_interface() {
Copy link

Choose a reason for hiding this comment

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

Method name "Product::register_interface" is not in camel caps format

},
]
);
public static function register_interface() {
Copy link

Choose a reason for hiding this comment

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

Opening brace should be on a new line

);
public static function register_interface() {

// Register the fields to the Product Interface
Copy link

Choose a reason for hiding this comment

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

Spaces must be used to indent lines; tabs are not allowed

public static function register_interface() {

// Register the fields to the Product Interface
// the product interface is defined by the post_type registration
Copy link

Choose a reason for hiding this comment

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

Spaces must be used to indent lines; tabs are not allowed


// Register the fields to the Product Interface
// the product interface is defined by the post_type registration
register_graphql_fields( 'Product', self::get_fields() );
Copy link

Choose a reason for hiding this comment

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

Spaces must be used to indent lines; tabs are not allowed


// Register the fields to the Product Interface
// the product interface is defined by the post_type registration
register_graphql_fields( 'Product', self::get_fields() );
Copy link

Choose a reason for hiding this comment

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

Space after opening parenthesis of function call prohibited


// Register the fields to the Product Interface
// the product interface is defined by the post_type registration
register_graphql_fields( 'Product', self::get_fields() );
Copy link

Choose a reason for hiding this comment

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

Expected 0 spaces before closing bracket; 1 found

@codeclimate
Copy link

codeclimate bot commented Dec 7, 2022

Code Climate has analyzed commit f6bc929 and detected 287 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 3
Duplication 4
Style 272
Clarity 5
Bug Risk 3

The test coverage on the diff in this pull request is 66.1% (50% is the threshold).

This pull request will bring the total coverage in the repository to 74.2% (-2.0% change).

View more on Code Climate.

@kidunot89 kidunot89 merged commit 0b8ce4f into wp-graphql:develop Dec 7, 2022
@kidunot89 kidunot89 added bugfix Implements bugfix breaking change Solution will break some older solutions labels Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Solution will break some older solutions bugfix Implements bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not working with WPGraphQL v1.13+
2 participants