@@ -83,6 +83,18 @@ public function mutate(string $query, array $variables, bool $withExtensions = f
83
83
);
84
84
}
85
85
86
+ public function getBulkOperation (int $ id ): GraphQLClientTransformer
87
+ {
88
+ $ response = $ this ->makeGetBulkOperationRequest ($ id );
89
+
90
+ /** @var ?array $response */
91
+ $ response = data_get ($ response , 'data.node ' , []);
92
+
93
+ return new GraphQLClientTransformer (
94
+ data: $ response ?? []
95
+ );
96
+ }
97
+
86
98
public function getCurrentBulkOperation (): GraphQLClientTransformer
87
99
{
88
100
$ response = $ this ->makeGetCurrentBulkOperationRequest ();
@@ -203,6 +215,17 @@ private function makeMutationRequest(string $query, array $variables, bool $with
203
215
return $ response ;
204
216
}
205
217
218
+ private function makeGetBulkOperationRequest (int $ id ): array
219
+ {
220
+ throw_if ($ this ->connector === null , ClientNotInitializedException::class);
221
+
222
+ $ response = $ this ->connector ->create ()->getBulkOperation ($ id );
223
+
224
+ throw_if ($ response ->failed (), ClientRequestFailedException::class, $ response );
225
+
226
+ return Arr::wrap ($ response ->json ());
227
+ }
228
+
206
229
/**
207
230
* @throws ClientNotInitializedException
208
231
* @throws ClientRequestFailedException
@@ -237,12 +260,17 @@ private function makeCreateBulkOperationRequest(string $query): array
237
260
* @throws ClientNotInitializedException
238
261
* @throws ClientRequestFailedException
239
262
*/
240
- private function makeCancelBulkOperationRequest (): array
263
+ private function makeCancelBulkOperationRequest (? int $ id = null ): array
241
264
{
242
265
throw_if ($ this ->connector === null , ClientNotInitializedException::class);
243
266
244
267
/** @var array $currentBulkOperation */
245
- $ currentBulkOperation = data_get ($ this ->makeGetCurrentBulkOperationRequest (), 'data.currentBulkOperation ' );
268
+ $ currentBulkOperation = when (
269
+ condition: $ id !== null ,
270
+ // @phpstan-ignore argument.type
271
+ value: data_get ($ this ->makeGetBulkOperationRequest ($ id ), 'data.node ' ),
272
+ default: data_get ($ this ->makeGetCurrentBulkOperationRequest (), 'data.currentBulkOperation ' ),
273
+ );
246
274
/** @var ?string $currentBulkOperationId */
247
275
$ currentBulkOperationId = data_get ($ currentBulkOperation , 'id ' );
248
276
/** @var ?string $currentBulkOperationStatus */
0 commit comments