-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Queries and mutations for shipping zones, tax classes, and tax …
…rates. (#856) * fix: General bugfixes and improvements * devops: New mutations and types tested and compliance with Linter and PHPStan * chore: hooks added to the mutation resolvers * feat: permission checks added * chore: Linter and compliance met * chore: Linter and compliance met
- Loading branch information
Showing
49 changed files
with
4,602 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* Connection - Shipping_Zones | ||
* | ||
* Registers connections to ShippingZone | ||
* | ||
* @package WPGraphQL\WooCommerce\Connection | ||
* @since TBD | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce\Connection; | ||
|
||
use GraphQL\Type\Definition\ResolveInfo; | ||
use WPGraphQL\AppContext; | ||
use WPGraphQL\WooCommerce\Data\Connection\Shipping_Zone_Connection_Resolver; | ||
|
||
/** | ||
* Class - Shipping_Zones | ||
*/ | ||
class Shipping_Zones { | ||
/** | ||
* Registers the various connections from other Types to ShippingZone | ||
* | ||
* @return void | ||
*/ | ||
public static function register_connections() { | ||
// From RootQuery. | ||
register_graphql_connection( self::get_connection_config() ); | ||
} | ||
|
||
/** | ||
* Given an array of $args, this returns the connection config, merging the provided args | ||
* with the defaults. | ||
* | ||
* @param array $args - Connection configuration. | ||
* @return array | ||
*/ | ||
public static function get_connection_config( $args = [] ): array { | ||
return array_merge( | ||
[ | ||
'fromType' => 'RootQuery', | ||
'toType' => 'ShippingZone', | ||
'fromFieldName' => 'shippingZones', | ||
'connectionArgs' => [], | ||
'resolve' => static function ( $source, array $args, AppContext $context, ResolveInfo $info ) { | ||
$resolver = new Shipping_Zone_Connection_Resolver( $source, $args, $context, $info ); | ||
|
||
return $resolver->get_connection(); | ||
}, | ||
], | ||
$args | ||
); | ||
} | ||
|
||
/** | ||
* Returns array of where args. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_connection_args(): array { | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* Connection - Tax_Classes | ||
* | ||
* Registers connections to TaxClass | ||
* | ||
* @package WPGraphQL\WooCommerce\Connection | ||
* @since TBD | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce\Connection; | ||
|
||
use GraphQL\Type\Definition\ResolveInfo; | ||
use WPGraphQL\AppContext; | ||
use WPGraphQL\WooCommerce\Data\Connection\Tax_Class_Connection_Resolver; | ||
|
||
/** | ||
* Class - TaxClass | ||
*/ | ||
class Tax_Classes { | ||
/** | ||
* Registers the various connections from other Types to TaxClass | ||
* | ||
* @return void | ||
*/ | ||
public static function register_connections() { | ||
// From RootQuery. | ||
register_graphql_connection( self::get_connection_config() ); | ||
} | ||
|
||
/** | ||
* Given an array of $args, this returns the connection config, merging the provided args | ||
* with the defaults. | ||
* | ||
* @param array $args - Connection configuration. | ||
* @return array | ||
*/ | ||
public static function get_connection_config( $args = [] ): array { | ||
return array_merge( | ||
[ | ||
'fromType' => 'RootQuery', | ||
'toType' => 'TaxClass', | ||
'fromFieldName' => 'taxClasses', | ||
'connectionArgs' => [], | ||
'resolve' => static function ( $source, array $args, AppContext $context, ResolveInfo $info ) { | ||
$resolver = new Tax_Class_Connection_Resolver( $source, $args, $context, $info ); | ||
|
||
return $resolver->get_connection(); | ||
}, | ||
], | ||
$args | ||
); | ||
} | ||
|
||
/** | ||
* Returns array of where args. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_connection_args(): array { | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.