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

Release v0.3.0 #155

Merged
merged 27 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
80048da
new WPGraphQL and WPGraphQL ACF hooks implemented
kidunot89 Sep 17, 2019
6e45741
Refactored to work with coming changes in "WPGraphQL"
kidunot89 Sep 17, 2019
971f4ea
""ProductUnion" type implemented.
kidunot89 Oct 18, 2019
803ff66
Acceptance and functional test queries updated.
kidunot89 Oct 18, 2019
ad033fd
centralizes "resolve_node*" hooks
kidunot89 Oct 24, 2019
9b4ca45
version numbers updated.
kidunot89 Oct 24, 2019
8598a87
Merge branch 'develop' of github.com:wp-graphql/wp-graphql-woocommerc…
kidunot89 Oct 24, 2019
34f0538
Merge branch 'develop' of github.com:wp-graphql/wp-graphql-woocommerc…
kidunot89 Oct 24, 2019
920f875
Unnecessary constant removed
kidunot89 Oct 24, 2019
594cb95
Merge branch 'release-v0.3.0' into wp-graphql-v0.4.0-support
kidunot89 Oct 24, 2019
245e4b3
Merge branch 'release-v0.3.0' into feature/product-union
kidunot89 Oct 24, 2019
91d7377
Merge branch 'release-v0.3.0' into feature/wp-graphql-acf-integration
kidunot89 Oct 24, 2019
9208240
.travis.yml updated
kidunot89 Oct 24, 2019
ba6adfe
"WPObjectType::node_interface()" to "Node"
kidunot89 Oct 24, 2019
9263944
Merge pull request #156 from kidunot89/wp-graphql-v0.4.0-support
kidunot89 Oct 24, 2019
95f4402
vendor rebuilt
kidunot89 Oct 24, 2019
63bbdfb
Merge branch 'release-v0.3.0' into feature/wp-graphql-acf-integration
kidunot89 Oct 24, 2019
4d76e99
Remove debug statement
kidunot89 Oct 24, 2019
360a303
vendor rebuilt
kidunot89 Oct 24, 2019
a9033bb
Merge pull request #158 from kidunot89/feature/wp-graphql-acf-integra…
kidunot89 Oct 24, 2019
f8c5277
Merge branch 'release-v0.3.0' into feature/product-interface
kidunot89 Oct 24, 2019
52ceafc
"ProductUnion" to "Product"
kidunot89 Oct 25, 2019
5de4aa4
"*product" added to "RootQuery"
kidunot89 Oct 25, 2019
9fef297
Merge pull request #159 from kidunot89/feature/product-interface
kidunot89 Oct 25, 2019
22deb98
Namespaces refactored.
kidunot89 Oct 25, 2019
af69f35
Merge pull request #160 from kidunot89/namespace-refactoring
kidunot89 Oct 25, 2019
58a9096
"@since" tag updated
kidunot89 Oct 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .phpcs.ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
<property name="prefixes" type="array" value="WPGraphQL\Extensions\WooCommerce"/>
<property name="prefixes" type="array" value="WPGraphQL\WooCommerce"/>
</properties>
</rule>
<rule ref="WordPress.WP.I18n">
Expand Down
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ branches:
only:
- develop
- master
- release-v0.2.0
- release-v0.2.1
- release-v0.1.2
- release-v0.2.2
- release-v0.3.0

cache:
apt: true
directories:
- vendor
- $HOME/.composer/cache

matrix:
Expand Down
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: GraphQL, WooCommerce, WPGraphQL
Requires at least: 4.9
Tested up to: 5.2
Requires PHP: 5.6
Stable tag: 0.2.2
Stable tag: 0.3.0
License: GPL-3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Maintained at: https://github.com/wp-graphql/wp-graphql-woocommerce
Expand Down
21 changes: 1 addition & 20 deletions access-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,10 @@
/**
* This file contains access functions for various class methods
*
* @package WPGraphQL\Extensions\WooCommerce
* @package WPGraphQL\WooCommerce
* @since 0.0.1
*/

/**
* Adds an ObjectType to the TypeRegistry and node resolvers to Relay node definitions.
*
* @param string $type_name The name of the Type to register.
* @param array $config The Type config.
*/
function wc_register_graphql_object_type( $type_name, $config ) {
$config['kind'] = 'object';
if ( ! empty( $config['resolve_node'] ) ) {
add_filter( 'graphql_resolve_node', $config['resolve_node'], 10, 4 );
unset( $config['resolve_node'] );
}
if ( ! empty( $config['resolve_node_type'] ) ) {
add_filter( 'graphql_resolve_node_type', $config['resolve_node_type'], 10, 2 );
unset( $config['resolve_node_type'] );
}
register_graphql_type( $type_name, $config );
}

/**
* Checks if source string starts with the target string
*
Expand Down
2 changes: 1 addition & 1 deletion class-inflect.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* @author @tbrianjones
* @link https://gist.github.com/tbrianjones/ba0460cc1d55f357e00b
* @package WPGraphQL\Extensions\WooCommerce
* @package WPGraphQL\WooCommerce
* @since 0.0.4
*/

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wp-graphql/wp-graphql-woocommerce",
"description": "WooCommerce bindings for wp-graphql",
"version": "0.2.2",
"version": "0.3.0",
"type": "wordpress-plugin",
"keywords": [
"wordpress",
Expand Down Expand Up @@ -35,7 +35,7 @@
"includes/connection/common-post-type-args.php"
],
"psr-4": {
"WPGraphQL\\Extensions\\WooCommerce\\": "includes/"
"WPGraphQL\\WooCommerce\\": "includes/"
},
"classmap": [
"includes/"
Expand Down
41 changes: 41 additions & 0 deletions includes/class-acf-schema-filters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Adds filters that modify WPGraphQL ACF schema.
*
* @package \WPGraphQL\WooCommerce
* @since 0.3.0
*/

namespace WPGraphQL\WooCommerce;

/**
* Class ACF_Schema_Filters
*/
class ACF_Schema_Filters {

/**
* Register filters
*/
public static function add_filters() {
// Registers WooCommerce CPTs && taxonomies.
add_filter( 'graphql_acf_get_root_id', array( __CLASS__, 'resolve_crud_root_id' ), 10, 2 );
}

/**
* Resolve post object ID from CRUD object Model.
*
* @param integer|null $id Post object database ID.
* @param mixed $root Root resolver.
*
* @return integer|null
*/
public static function resolve_crud_root_id( $id, $root ) {
switch ( true ) {
case $root instanceof \WPGraphQL\WooCommerce\Model\CRUD_CPT:
$id = absint( $root->ID );
break;
}

return $id;
}
}
95 changes: 88 additions & 7 deletions includes/class-core-schema-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
/**
* Adds filters that modify core schema.
*
* @package \WPGraphQL\Extensions\WooCommerce
* @package \WPGraphQL\WooCommerce
* @since 0.0.1
*/

namespace WPGraphQL\Extensions\WooCommerce;
namespace WPGraphQL\WooCommerce;

use WPGraphQL\Extensions\WooCommerce\Data\Loader\WC_Customer_Loader;
use WPGraphQL\Extensions\WooCommerce\Data\Loader\WC_Post_Crud_Loader;
use WPGraphQL\WooCommerce\Data\Loader\WC_Customer_Loader;
use WPGraphQL\WooCommerce\Data\Loader\WC_Post_Crud_Loader;

/**
* Class Core_Schema_Filters
Expand All @@ -33,6 +33,11 @@ class Core_Schema_Filters {
* Register filters
*/
public static function add_filters() {
// Registers WooCommerce CPTs.
add_filter( 'register_post_type_args', array( __CLASS__, 'register_post_types' ), 10, 2 );
add_filter( 'graphql_post_entities_allowed_post_types', array( __CLASS__, 'skip_type_registry' ), 10 );
add_filter( 'graphql_union_resolve_type', array( __CLASS__, 'graphql_union_resolve_type' ), 10, 3 );

// Registers WooCommerce taxonomies.
add_filter( 'register_taxonomy_args', array( __CLASS__, 'register_taxonomy_args' ), 10, 2 );

Expand All @@ -43,7 +48,7 @@ public static function add_filters() {
add_filter(
'graphql_post_object_connection_query_args',
array(
'\WPGraphQL\Extensions\WooCommerce\Data\Connection\Post_Connection_Resolver',
'\WPGraphQL\WooCommerce\Data\Connection\Post_Connection_Resolver',
'get_query_args',
),
10,
Expand All @@ -52,12 +57,26 @@ public static function add_filters() {
add_filter(
'graphql_term_object_connection_query_args',
array(
'\WPGraphQL\Extensions\WooCommerce\Data\Connection\WC_Terms_Connection_Resolver',
'\WPGraphQL\WooCommerce\Data\Connection\WC_Terms_Connection_Resolver',
'get_query_args',
),
10,
5
);

// Add node resolvers.
add_filter(
'graphql_resolve_node',
array( '\WPGraphQL\WooCommerce\Data\Factory', 'resolve_node' ),
10,
4
);
add_filter(
'graphql_resolve_node_type',
array( '\WPGraphQL\WooCommerce\Data\Factory', 'resolve_node_type' ),
10,
2
);
}

/**
Expand Down Expand Up @@ -88,10 +107,72 @@ public static function customer_loader( $context ) {
return self::$customer_loader;
}

/**
* Registers WooCommerce post-types to be used in GraphQL schema
*
* @param array $args - allowed post-types.
* @param string $post_type - name of taxonomy being checked.
*
* @return array
*/
public static function register_post_types( $args, $post_type ) {
if ( 'product' === $post_type ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'Product';
$args['graphql_plural_name'] = 'Products';
$args['skip_graphql_type_registry'] = true;
}
if ( 'product_variation' === $post_type ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'ProductVariation';
$args['graphql_plural_name'] = 'ProductVariations';
$args['skip_graphql_type_registry'] = true;
}
if ( 'shop_coupon' === $post_type ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'Coupon';
$args['graphql_plural_name'] = 'Coupons';
$args['skip_graphql_type_registry'] = true;
}
if ( 'shop_order' === $post_type ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'Order';
$args['graphql_plural_name'] = 'Orders';
$args['skip_graphql_type_registry'] = true;
}
if ( 'shop_order_refund' === $post_type ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'Refund';
$args['graphql_plural_name'] = 'Refunds';
$args['skip_graphql_type_registry'] = true;
}

return $args;
}

/**
* Filters "allowed_post_types" and removed Woocommerce CPTs.
*
* @param array $post_types Post types registered in GraphQL schema.
*
* @return array
*/
public static function skip_type_registry( $post_types ) {
return array_diff(
$post_types,
get_post_types(
[
'show_in_graphql' => true,
'skip_graphql_type_registry' => true,
]
)
);
}

/**
* Registers WooCommerce taxonomies to be used in GraphQL schema
*
* @param array $args - allowed post-types.
* @param array $args - allowed taxonomies.
* @param string $taxonomy - name of taxonomy being checked.
*
* @return array
Expand Down
4 changes: 2 additions & 2 deletions includes/class-jwt-auth-schema-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Adds filters that modify the WooGraphQL schema to include WPGraphQL JWT Authentication
* fields in Customer type and mutations.
*
* @package \WPGraphQL\Extensions\WooCommerce
* @package \WPGraphQL\WooCommerce
* @since 0.2.2
*/

namespace WPGraphQL\Extensions\WooCommerce;
namespace WPGraphQL\WooCommerce;

use GraphQL\Error\UserError;
use GraphQL\Type\Definition\ResolveInfo;
Expand Down
Loading