@@ -364,51 +364,52 @@ class ExperimentalIncrementalExecutionResults(NamedTuple):
364
364
class FormattedIncrementalDeferResult (TypedDict , total = False ):
365
365
"""Formatted incremental deferred execution result"""
366
366
367
- data : dict [str , Any ] | None
368
- errors : list [GraphQLFormattedError ]
367
+ data : dict [str , Any ]
369
368
path : list [str | int ]
369
+ errors : list [GraphQLFormattedError ]
370
370
extensions : dict [str , Any ]
371
371
372
372
373
373
class IncrementalDeferResult :
374
374
"""Incremental deferred execution result"""
375
375
376
- data : dict [str , Any ] | None
376
+ data : dict [str , Any ]
377
+ path : list [str | int ]
377
378
errors : list [GraphQLError ] | None
378
- path : list [str | int ] | None
379
379
extensions : dict [str , Any ] | None
380
380
381
381
__slots__ = "data" , "errors" , "extensions" , "path"
382
382
383
383
def __init__ (
384
384
self ,
385
- data : dict [str , Any ] | None = None ,
385
+ data : dict [str , Any ],
386
+ path : list [str | int ],
386
387
errors : list [GraphQLError ] | None = None ,
387
- path : list [str | int ] | None = None ,
388
388
extensions : dict [str , Any ] | None = None ,
389
389
) -> None :
390
390
self .data = data
391
- self .errors = errors
392
391
self .path = path
392
+ self .errors = errors
393
393
self .extensions = extensions
394
394
395
395
def __repr__ (self ) -> str :
396
396
name = self .__class__ .__name__
397
- args : list [str ] = [f"data={ self .data !r} , errors ={ self .errors !r} " ]
398
- if self .path :
399
- args .append (f"path ={ self .path !r} " )
397
+ args : list [str ] = [f"data={ self .data !r} , path ={ self .path !r} " ]
398
+ if self .errors :
399
+ args .append (f"errors ={ self .errors !r} " )
400
400
if self .extensions :
401
401
args .append (f"extensions={ self .extensions } " )
402
402
return f"{ name } ({ ', ' .join (args )} )"
403
403
404
404
@property
405
405
def formatted (self ) -> FormattedIncrementalDeferResult :
406
406
"""Get execution result formatted according to the specification."""
407
- formatted : FormattedIncrementalDeferResult = {"data" : self .data }
407
+ formatted : FormattedIncrementalDeferResult = {
408
+ "data" : self .data ,
409
+ "path" : self .path ,
410
+ }
408
411
if self .errors is not None :
409
412
formatted ["errors" ] = [error .formatted for error in self .errors ]
410
- if self .path is not None :
411
- formatted ["path" ] = self .path
412
413
if self .extensions is not None :
413
414
formatted ["extensions" ] = self .extensions
414
415
return formatted
@@ -442,51 +443,52 @@ def __ne__(self, other: object) -> bool:
442
443
class FormattedIncrementalStreamResult (TypedDict , total = False ):
443
444
"""Formatted incremental stream execution result"""
444
445
445
- items : list [Any ] | None
446
- errors : list [GraphQLFormattedError ]
446
+ items : list [Any ]
447
447
path : list [str | int ]
448
+ errors : list [GraphQLFormattedError ]
448
449
extensions : dict [str , Any ]
449
450
450
451
451
452
class IncrementalStreamResult :
452
453
"""Incremental streamed execution result"""
453
454
454
- items : list [Any ] | None
455
+ items : list [Any ]
456
+ path : list [str | int ]
455
457
errors : list [GraphQLError ] | None
456
- path : list [str | int ] | None
457
458
extensions : dict [str , Any ] | None
458
459
459
460
__slots__ = "errors" , "extensions" , "items" , "label" , "path"
460
461
461
462
def __init__ (
462
463
self ,
463
- items : list [Any ] | None = None ,
464
+ items : list [Any ],
465
+ path : list [str | int ],
464
466
errors : list [GraphQLError ] | None = None ,
465
- path : list [str | int ] | None = None ,
466
467
extensions : dict [str , Any ] | None = None ,
467
468
) -> None :
468
469
self .items = items
469
- self .errors = errors
470
470
self .path = path
471
+ self .errors = errors
471
472
self .extensions = extensions
472
473
473
474
def __repr__ (self ) -> str :
474
475
name = self .__class__ .__name__
475
- args : list [str ] = [f"items={ self .items !r} , errors ={ self .errors !r} " ]
476
- if self .path :
477
- args .append (f"path ={ self .path !r} " )
476
+ args : list [str ] = [f"items={ self .items !r} , path ={ self .path !r} " ]
477
+ if self .errors :
478
+ args .append (f"errors ={ self .errors !r} " )
478
479
if self .extensions :
479
480
args .append (f"extensions={ self .extensions } " )
480
481
return f"{ name } ({ ', ' .join (args )} )"
481
482
482
483
@property
483
484
def formatted (self ) -> FormattedIncrementalStreamResult :
484
485
"""Get execution result formatted according to the specification."""
485
- formatted : FormattedIncrementalStreamResult = {"items" : self .items }
486
- if self .errors is not None :
486
+ formatted : FormattedIncrementalStreamResult = {
487
+ "items" : self .items ,
488
+ "path" : self .path ,
489
+ }
490
+ if self .errors :
487
491
formatted ["errors" ] = [error .formatted for error in self .errors ]
488
- if self .path is not None :
489
- formatted ["path" ] = self .path
490
492
if self .extensions is not None :
491
493
formatted ["extensions" ] = self .extensions
492
494
return formatted
@@ -982,8 +984,8 @@ def _process_pending(
982
984
continue
983
985
incremental_result = IncrementalStreamResult (
984
986
subsequent_result_record .items ,
985
- subsequent_result_record .errors or None ,
986
987
subsequent_result_record .stream_record .path ,
988
+ subsequent_result_record .errors or None ,
987
989
)
988
990
incremental_results .append (incremental_result )
989
991
else :
@@ -997,9 +999,9 @@ def _process_pending(
997
999
if not deferred_grouped_field_set_record .sent :
998
1000
deferred_grouped_field_set_record .sent = True
999
1001
incremental_result = IncrementalDeferResult (
1000
- deferred_grouped_field_set_record .data ,
1001
- deferred_grouped_field_set_record .errors or None ,
1002
+ deferred_grouped_field_set_record .data , # type: ignore
1002
1003
deferred_grouped_field_set_record .path ,
1004
+ deferred_grouped_field_set_record .errors or None ,
1003
1005
)
1004
1006
incremental_results .append (incremental_result )
1005
1007
return IncrementalUpdate (
0 commit comments