self::get_input_fields(), 'outputFields' => self::get_output_fields(), 'mutateAndGetPayload' => [ Product_Create::class, 'mutate_and_get_payload' ], ] ); } /** * Defines the mutation input field configuration * * @return array */ public static function get_input_fields() { return array_merge( Product_Create::get_input_fields(), [ 'id' => [ 'type' => [ 'non_null' => 'ID' ], 'description' => static function () { return __( 'Unique identifier for the product.', 'graphql-for-ecommerce' ); }, ], 'name' => [ 'type' => 'String', 'description' => static function () { return __( 'Name of the product.', 'graphql-for-ecommerce' ); }, ], ] ); } /** * Defines the mutation output field configuration * * @return array */ public static function get_output_fields() { return [ 'product' => [ 'type' => 'Product', 'resolve' => static function ( $payload ) { return new Product( $payload['id'] ); }, ], ]; } }