bigcommerce / bigcommerce-for-wordpress

A headless commerce integration for WordPress, powered by BigCommerce
https://www.bigcommerce.com/wordpress/
GNU General Public License v2.0
109 stars 48 forks source link

Add fields in WPGraphql #337

Closed asimonok closed 2 years ago

asimonok commented 2 years ago

is there any ways/recommendations/links how to add fields from bigcommerce products/categories in wpgraphql schema (image, price, sku and etc)?

Now we add custom post type and taxonomy into theme files but it would be great to have extension that can do that automatically like https://www.wpgraphql.com/extenstion-plugins/wpgraphql-for-advanced-custom-fields/ but for BigCommerce entities

// manually add mapping for bc product post type and bc category taxonomy

add_filter( 'register_post_type_args', function( $args, $post_type ) {

// Change this to the post type you are adding support for

if ( 'bigcommerce_product' === $post_type ) {

$args['show_in_graphql'] = true;

$args['graphql_single_name'] = 'BCProduct';

$args['graphql_plural_name'] = 'BCProducts';

}

return $args;

}, 10, 2 );

add_filter( 'register_taxonomy_args', function( $args, $taxonomy ) {

if ( 'bigcommerce_category' === $taxonomy ) {

$args['show_in_graphql'] = true;

$args['graphql_single_name'] = 'BCCategory';

$args['graphql_plural_name'] = 'BCCategories';

}

return $args;

}, 10, 2 );
yuenvision commented 2 years ago

This is an intriguing feature request. I'll ticket the team a sprint or two out to timebox a spike and look into it.

tyla-taylor commented 2 years ago

Addressed in version 4.28