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

Coupon mutations added. #510

Merged
merged 7 commits into from
Jul 5, 2021
Merged

Coupon mutations added. #510

merged 7 commits into from
Jul 5, 2021

Conversation

kidunot89
Copy link
Member

@kidunot89 kidunot89 commented Jun 13, 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 coupon mutations. See example below.
mutation($input: CreateCouponInput!) {
	createCoupon(input: $input) {
		coupon {
			id
			databaseId
			code
			amount
			discountType
		}
	}
}
$variables = array(
	'input' => array(
		'clientMutationId' => 'some_id',
		'code'             => 'testcode',
		'amount'           => 0.25,
		'discountType'     => 'PERCENT',
	),
);
mutation($input: UpdateCouponInput!) {
	updateCoupon(input: $input) {
		coupon {
			id
			databaseId
			code
		}
	}
}
$variables = array(
	'input' => array(
		'clientMutationId' => 'some_id',
		'id'               => $this->toRelayId( 'shop_coupon', $coupon_id ),
		'code'             => 'blahblah',
		'amount'           => 0.25,
		'discountType'     => 'PERCENT',
	),
);
mutation($input: DeleteCouponInput!) {
	deleteCoupon(input: $input) {
		coupon {
			id
			databaseId
		}
	}
}
$variables = array(
	'input' => array(
		'clientMutationId' => 'some_id',
		'id'               => $this->toRelayId( 'shop_coupon', $coupon_id ),
	),
);

Does this close any currently open issues?

Resolves #14

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: v0.10.0
  • WPGraphQL Version: v1.4.3
  • WordPress Version:
  • WooCommerce Version:

@kidunot89 kidunot89 self-assigned this Jun 13, 2021
@kidunot89 kidunot89 added this to the v0.10.1 milestone Jun 27, 2021
@kidunot89 kidunot89 added enhancement New feature or request new mutations Feature adds mutation(s) to the schema labels Jun 27, 2021
@kidunot89 kidunot89 force-pushed the feature/coupon-mutations branch 12 times, most recently from a650297 to 9a4f3ef Compare July 1, 2021 00:16
public static function mutate_and_get_payload( $input, AppContext $context, ResolveInfo $info ) {
// Retrieve order ID.
$coupon_id = 0;
if ( ! empty( $input['id'] ) && is_numeric( $input['id'] ) ) {
Copy link

Choose a reason for hiding this comment

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

Identical blocks of code found in 2 locations. Consider refactoring.

public static function mutate_and_get_payload( $input, AppContext $context, ResolveInfo $info ) {
// Retrieve order ID.
$coupon_id = 0;
if ( ! empty( $input['id'] ) && is_numeric( $input['id'] ) ) {
Copy link

Choose a reason for hiding this comment

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

Identical blocks of code found in 2 locations. Consider refactoring.

*
* @return callable
*/
public static function mutate_and_get_payload( $input, AppContext $context, ResolveInfo $info ) {
Copy link

Choose a reason for hiding this comment

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

Function mutate_and_get_payload has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

*
* @return callable
*/
public static function mutate_and_get_payload( $input, AppContext $context, ResolveInfo $info ) {
Copy link

Choose a reason for hiding this comment

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

Function mutate_and_get_payload has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.

@kidunot89 kidunot89 force-pushed the feature/coupon-mutations branch 2 times, most recently from c62bf3b to 85a5336 Compare July 2, 2021 15:07
@codeclimate
Copy link

codeclimate bot commented Jul 2, 2021

There are too many results to compare

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

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

View more on Code Climate.

@kidunot89 kidunot89 merged commit f59872a into develop Jul 5, 2021
@kidunot89 kidunot89 deleted the feature/coupon-mutations branch July 5, 2021 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new mutations Feature adds mutation(s) to the schema
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coupon Mutations
1 participant