@@ -26,24 +26,28 @@ class Product_Attributes {
2626 */
2727 public static function register_connections () {
2828 // From Product to ProductAttribute.
29- register_graphql_connection ( self ::get_connection_config () );
29+ register_graphql_connection (
30+ self ::get_connection_config ()
31+ );
3032
3133 // From Product to LocalProductAttribute.
3234 register_graphql_connection (
3335 self ::get_connection_config (
3436 [
35- 'toType ' => 'LocalProductAttribute ' ,
36- 'fromFieldName ' => 'localAttributes ' ,
37- ]
37+ 'toType ' => 'LocalProductAttribute ' ,
38+ 'fromFieldName ' => 'localAttributes ' ,
39+ 'connectionArgs ' => [],
40+ ],
3841 )
3942 );
4043
4144 // From Product to GlobalProductAttribute.
4245 register_graphql_connection (
4346 self ::get_connection_config (
4447 [
45- 'toType ' => 'GlobalProductAttribute ' ,
46- 'fromFieldName ' => 'globalAttributes ' ,
48+ 'toType ' => 'GlobalProductAttribute ' ,
49+ 'fromFieldName ' => 'globalAttributes ' ,
50+ 'connectionArgs ' => [],
4751 ]
4852 )
4953 );
@@ -65,8 +69,15 @@ public static function get_connection_config( $args = [] ): array {
6569 'connectionArgs ' => self ::get_connection_args (),
6670 'resolve ' => function ( $ source , array $ args , AppContext $ context , ResolveInfo $ info ) {
6771 $ resolver = new Product_Attribute_Connection_Resolver ();
68-
69- return $ resolver ->resolve ( $ source , $ args , $ context , $ info );
72+ // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
73+ switch ( $ info ->fieldName ) {
74+ case 'globalAttributes ' :
75+ return $ resolver ->resolve ( $ source , $ args , $ context , $ info , 'global ' );
76+ case 'localAttributes ' :
77+ return $ resolver ->resolve ( $ source , $ args , $ context , $ info , 'local ' );
78+ default :
79+ return $ resolver ->resolve ( $ source , $ args , $ context , $ info );
80+ }
7081 },
7182 ],
7283 $ args
0 commit comments