@@ -205,8 +205,8 @@ protected static function buildExecutionContext(
205
205
return $ errors ;
206
206
}
207
207
208
- assert ($ operation instanceof OperationDefinitionNode, 'Has operation if no errors. ' );
209
- assert (\is_array ($ variableValues ), 'Has variables if no errors. ' );
208
+ \ assert ($ operation instanceof OperationDefinitionNode, 'Has operation if no errors. ' );
209
+ \ assert (\is_array ($ variableValues ), 'Has variables if no errors. ' );
210
210
211
211
return new ExecutionContext (
212
212
$ schema ,
@@ -536,18 +536,17 @@ protected function executeFieldsSerially(ObjectType $parentType, $rootValue, arr
536
536
\array_keys ($ fields ->getArrayCopy ()),
537
537
function ($ results , $ responseName ) use ($ contextValue , $ path , $ unaliasedPath , $ parentType , $ rootValue , $ fields ) {
538
538
$ fieldNodes = $ fields [$ responseName ];
539
- assert ($ fieldNodes instanceof \ArrayObject, 'The keys of $fields populate $responseName ' );
539
+ \ assert ($ fieldNodes instanceof \ArrayObject, 'The keys of $fields populate $responseName ' );
540
540
541
- $ fieldPath = $ path ;
542
- $ fieldPath [] = $ responseName ;
543
-
544
- $ fieldNode = $ fieldNodes [0 ];
545
- assert ($ fieldNode instanceof FieldNode, '$fieldNodes is non-empty ' );
546
-
547
- $ fieldUnaliasedPath = $ unaliasedPath ;
548
- $ fieldUnaliasedPath [] = $ fieldNode ->name ->value ;
549
-
550
- $ result = $ this ->resolveField ($ parentType , $ rootValue , $ fieldNodes , $ fieldPath , $ fieldUnaliasedPath , $ this ->maybeScopeContext ($ contextValue ));
541
+ $ result = $ this ->resolveField (
542
+ $ parentType ,
543
+ $ rootValue ,
544
+ $ fieldNodes ,
545
+ $ responseName ,
546
+ $ path ,
547
+ $ unaliasedPath ,
548
+ $ this ->maybeScopeContext ($ contextValue )
549
+ );
551
550
if ($ result === static ::$ UNDEFINED ) {
552
551
return $ results ;
553
552
}
@@ -600,18 +599,29 @@ function ($results, $responseName) use ($contextValue, $path, $unaliasedPath, $p
600
599
*
601
600
* @return array<mixed>|\Throwable|mixed|null
602
601
*/
603
- protected function resolveField (ObjectType $ parentType , $ rootValue , \ArrayObject $ fieldNodes , array $ path , array $ unaliasedPath , $ contextValue )
604
- {
602
+ protected function resolveField (
603
+ ObjectType $ parentType ,
604
+ $ rootValue ,
605
+ \ArrayObject $ fieldNodes ,
606
+ string $ responseName ,
607
+ array $ path ,
608
+ array $ unaliasedPath ,
609
+ $ contextValue
610
+ ) {
605
611
$ exeContext = $ this ->exeContext ;
612
+
606
613
$ fieldNode = $ fieldNodes [0 ];
607
- assert ($ fieldNode instanceof FieldNode, '$fieldNodes is non-empty ' );
614
+ \ assert ($ fieldNode instanceof FieldNode, '$fieldNodes is non-empty ' );
608
615
609
616
$ fieldName = $ fieldNode ->name ->value ;
610
617
$ fieldDef = $ this ->getFieldDef ($ exeContext ->schema , $ parentType , $ fieldName );
611
618
if ($ fieldDef === null || ! $ fieldDef ->isVisible ()) {
612
619
return static ::$ UNDEFINED ;
613
620
}
614
621
622
+ $ path [] = $ responseName ;
623
+ $ unaliasedPath [] = $ fieldName ;
624
+
615
625
$ returnType = $ fieldDef ->getType ();
616
626
// The resolve function's optional 3rd argument is a context value that
617
627
// is provided to every resolve function within an execution. It is commonly
@@ -892,11 +902,11 @@ protected function completeValue(
892
902
return $ this ->completeListValue ($ returnType , $ fieldNodes , $ info , $ path , $ unaliasedPath , $ result , $ contextValue );
893
903
}
894
904
895
- assert ($ returnType instanceof NamedType, 'Wrapping types should return early ' );
905
+ \ assert ($ returnType instanceof NamedType, 'Wrapping types should return early ' );
896
906
897
907
// Account for invalid schema definition when typeLoader returns different
898
908
// instance than `resolveType` or $field->getType() or $arg->getType()
899
- assert (
909
+ \ assert (
900
910
$ returnType === $ this ->exeContext ->schema ->getType ($ returnType ->name ),
901
911
SchemaValidationContext::duplicateType ($ this ->exeContext ->schema , "{$ info ->parentType }. {$ info ->fieldName }" , $ returnType ->name )
902
912
);
@@ -1235,7 +1245,7 @@ protected function completeObjectValue(
1235
1245
});
1236
1246
}
1237
1247
1238
- assert (is_bool ($ isTypeOf ), 'Promise would return early ' );
1248
+ \ assert (is_bool ($ isTypeOf ), 'Promise would return early ' );
1239
1249
if (! $ isTypeOf ) {
1240
1250
throw $ this ->invalidReturnTypeError ($ returnType , $ result , $ fieldNodes );
1241
1251
}
@@ -1350,16 +1360,15 @@ protected function executeFields(ObjectType $parentType, $rootValue, array $path
1350
1360
$ containsPromise = false ;
1351
1361
$ results = [];
1352
1362
foreach ($ fields as $ responseName => $ fieldNodes ) {
1353
- $ fieldPath = $ path ;
1354
- $ fieldPath [] = $ responseName ;
1355
-
1356
- $ fieldNode = $ fieldNodes [0 ];
1357
- assert ($ fieldNode instanceof FieldNode, '$fieldNodes is non-empty ' );
1358
-
1359
- $ fieldUnaliasedPath = $ unaliasedPath ;
1360
- $ fieldUnaliasedPath [] = $ fieldNode ->name ->value ;
1361
-
1362
- $ result = $ this ->resolveField ($ parentType , $ rootValue , $ fieldNodes , $ fieldPath , $ fieldUnaliasedPath , $ this ->maybeScopeContext ($ contextValue ));
1363
+ $ result = $ this ->resolveField (
1364
+ $ parentType ,
1365
+ $ rootValue ,
1366
+ $ fieldNodes ,
1367
+ $ responseName ,
1368
+ $ path ,
1369
+ $ unaliasedPath ,
1370
+ $ this ->maybeScopeContext ($ contextValue )
1371
+ );
1363
1372
if ($ result === static ::$ UNDEFINED ) {
1364
1373
continue ;
1365
1374
}
@@ -1449,12 +1458,12 @@ protected function ensureValidRuntimeType(
1449
1458
throw new InvariantViolation ("Runtime Object type \"{$ runtimeType }\" is not a possible type for \"{$ returnType }\". " );
1450
1459
}
1451
1460
1452
- assert (
1461
+ \ assert (
1453
1462
$ this ->exeContext ->schema ->getType ($ runtimeType ->name ) !== null ,
1454
1463
"Schema does not contain type \"{$ runtimeType }\". This can happen when an object type is only referenced indirectly through abstract types and never directly through fields.List the type in the option \"types \" during schema construction, see https://webonyx.github.io/graphql-php/schema-definition/#configuration-options. "
1455
1464
);
1456
1465
1457
- assert (
1466
+ \ assert (
1458
1467
$ runtimeType === $ this ->exeContext ->schema ->getType ($ runtimeType ->name ),
1459
1468
"Schema must contain unique named types but contains multiple types named \"{$ runtimeType }\". Make sure that `resolveType` function of abstract type \"{$ returnType }\" returns the same type instance as referenced anywhere else within the schema (see https://webonyx.github.io/graphql-php/type-definitions/#type-registry). "
1460
1469
);
0 commit comments