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

Updates to be compatible with WPGraphQL v1.6.1 #537

Merged

Conversation

kidunot89
Copy link
Member

@kidunot89 kidunot89 commented Aug 11, 2021

Your checklist for this pull request

Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

🚨Please review the guidelines for contributing to this repository.

  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Make sure you are requesting to pull request from a topic/feature/bugfix/devops branch (right side). Don't pull request from your master!
  • Have you ensured/updated that CLI tests to extend coverage to any new logic. Learn how to modify the tests here.

What does this implement/fix? Explain your changes.

  • Adds support for refined WPGraphQL lazy loading functionality
  • Fixes WPGraphQL v1.6x schema problems.
  • Some affect unit test refactored.
  • Thanks to @jasonbahl for tag teaming this with me 👐🏿 .
  • Fixes incompatibility with some older connections.

Does this close any currently open issues?

#536 #535 #533 #528

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

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?

Where has this been tested?

  • WooGraphQL Version: 0.8.1
  • WPGraphQL Version: 1.6.2
  • WordPress Version: 5.8
  • WooCommerce Version: 5.5.2

@kidunot89 kidunot89 added enhancement New feature or request bugfix Implements bugfix labels Aug 11, 2021
'description' => __( 'Total number of items in the cart.', 'wp-graphql-woocommerce' ),
'resolve' => function( $source ) {
if ( empty( $source['edges'] ) ) {
return 0;
Copy link

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.


$items = array_values( $source['edges'][0]['source']->get_cart() );
if ( empty( $items ) ) {
return 0;
Copy link

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.

return 0;
}

return array_sum( array_column( $items, 'quantity' ) );
Copy link

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.

'description' => __( 'Total number of different products in the cart', 'wp-graphql-woocommerce' ),
'resolve' => function( $source ) {
if ( empty( $source['edges'] ) ) {
return 0;
Copy link

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.

return 0;
}

return count( array_values( $source['edges'][0]['source']->get_cart() ) );
Copy link

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.

@kidunot89 kidunot89 force-pushed the bugfix/wp-graphql-v1.6x-support branch from d23b677 to bea0404 Compare August 11, 2021 18:00
'resolve' => function ( $source, array $args, AppContext $context, ResolveInfo $info ) {
$resolver = new Cart_Item_Connection_Resolver( $source, $args, $context, $info );

return $resolver->get_connection();
Copy link

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.

}

return $attributes;
return $data;
Copy link

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.

'description' => __( 'Attributes of the variation.', 'wp-graphql-woocommerce' ),
'resolve' => function( $source ) {
$attributes = array();
return $attributes;
Copy link

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.

} else {
$attributes[ $name ] = $default_value;
}
return $resolver->one_to_one()
Copy link

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.

}
}

return Variation_Attribute_Connection_Resolver::to_data_array( $attributes, $variation->ID );
Copy link

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.

@codeclimate
Copy link

codeclimate bot commented Aug 11, 2021

Code Climate has analyzed commit bea0404 and detected 117 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 21
Duplication 8
Style 75
Clarity 10
Bug Risk 3

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

This pull request will bring the total coverage in the repository to 77.0% (0.0% change).

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Implements bugfix enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants