1313use GraphQL \Error \UserError ;
1414use GraphQLRelay \Relay ;
1515use WPGraphQL \AppContext ;
16- use WPGraphQL \Data \DataSource ;
1716use WPGraphQL \WooCommerce \Data \Factory ;
1817
1918/**
@@ -75,8 +74,8 @@ public static function register() {
7574 ],
7675 'resolve ' => function ( $ source , $ args ) {
7776 if ( isset ( $ args ['format ' ] ) && 'raw ' === $ args ['format ' ] ) {
78- // @codingStandardsIgnoreLine.
79- return $ source ->priceRaw ;
77+ // @codingStandardsIgnoreLine.
78+ return $ source ->priceRaw ;
8079 } else {
8180 return $ source ->price ;
8281 }
@@ -93,11 +92,11 @@ public static function register() {
9392 ],
9493 'resolve ' => function ( $ source , $ args ) {
9594 if ( isset ( $ args ['format ' ] ) && 'raw ' === $ args ['format ' ] ) {
96- // @codingStandardsIgnoreLine.
97- return $ source ->regularPriceRaw ;
95+ // @codingStandardsIgnoreLine.
96+ return $ source ->regularPriceRaw ;
9897 } else {
99- // @codingStandardsIgnoreLine.
100- return $ source ->regularPrice ;
98+ // @codingStandardsIgnoreLine.
99+ return $ source ->regularPrice ;
101100 }
102101 },
103102 ],
@@ -112,11 +111,11 @@ public static function register() {
112111 ],
113112 'resolve ' => function ( $ source , $ args ) {
114113 if ( isset ( $ args ['format ' ] ) && 'raw ' === $ args ['format ' ] ) {
115- // @codingStandardsIgnoreLine.
116- return $ source ->salePriceRaw ;
114+ // @codingStandardsIgnoreLine.
115+ return $ source ->salePriceRaw ;
117116 } else {
118- // @codingStandardsIgnoreLine.
119- return $ source ->salePrice ;
117+ // @codingStandardsIgnoreLine.
118+ return $ source ->salePrice ;
120119 }
121120 },
122121 ],
@@ -232,7 +231,9 @@ public static function register() {
232231 'type ' => 'MediaItem ' ,
233232 'description ' => __ ( 'Product variation main image ' , 'wp-graphql-woocommerce ' ),
234233 'resolve ' => function ( $ source , array $ args , AppContext $ context ) {
235- return ! empty ( $ source ->image_id ) ? DataSource::resolve_post_object ( $ source ->image_id , $ context ) : null ;
234+ return ! empty ( $ source ->image_id )
235+ ? $ context ->get_loader ( 'post ' )->load_deferred ( $ source ->image_id )
236+ : null ;
236237 },
237238 ],
238239
0 commit comments