@@ -314,7 +314,7 @@ public function entityToGqlQueryArg($entity_type, $bundle = NULL) {
314
314
if ($ field_info ['type ' ] instanceof ListOfType) {
315
315
if (isset ($ this ->objectTypes [$ field ])) {
316
316
$ field_info ['type ' ] = $ this ->objectTypes [$ field ];
317
- }
317
+ }
318
318
else {
319
319
if (!($ field_info ['type ' ]->ofType instanceof \Closure) && !($ field_info ['type ' ]->ofType instanceof InterfaceType)) {
320
320
$ args [$ field ] = [
@@ -505,39 +505,41 @@ public function getFields($entity_type, $bundle = '') {
505
505
506
506
$ entity_info = $ this ->getEntityInfo ($ entity_type );
507
507
$ entity_keys = $ entity_info ['entity keys ' ];
508
- foreach ($ properties_info ['properties ' ] as $ property => $ info ) {
509
- $ fieldType = isset ($ info ['type ' ]) ? $ this ->gqlFieldType ($ info ['type ' ], [
510
- 'entity_type ' => $ entity_type ,
511
- 'bundle ' => NULL ,
512
- 'property ' => $ property ,
513
- 'info ' => $ info
514
- ]) : Type::string ();
515
-
516
- if (!$ fieldType ) {
517
- // dump($info);
518
- // die("Cannot detect fieldType for {$entity_type} {$property}");
519
- $ this ->addError ("Cannot detect fieldType for {$ entity_type } {$ property }" );
520
- continue ;
521
- }
508
+ if ($ properties_info ['properties ' ]) {
509
+ foreach ($ properties_info ['properties ' ] as $ property => $ info ) {
510
+ $ fieldType = isset ($ info ['type ' ]) ? $ this ->gqlFieldType ($ info ['type ' ], [
511
+ 'entity_type ' => $ entity_type ,
512
+ 'bundle ' => NULL ,
513
+ 'property ' => $ property ,
514
+ 'info ' => $ info
515
+ ]) : Type::string ();
516
+
517
+ if (!$ fieldType ) {
518
+ // dump($info);
519
+ // die("Cannot detect fieldType for {$entity_type} {$property}");
520
+ $ this ->addError ("Cannot detect fieldType for {$ entity_type } {$ property }" );
521
+ continue ;
522
+ }
522
523
523
- $ fields [$ property ] = [
524
- 'type ' => $ fieldType ,
525
- 'description ' => isset ($ info ['description ' ]) ? $ info ['description ' ] : '' ,
526
- 'resolve ' => function ($ value , $ args , $ context , ResolveInfo $ info ) use ($ entity_type , $ bundle , $ property ) {
527
- if (isset ($ value ->wrapper )) {
528
- $ wrap = $ value ->wrapper ();
529
- } else {
530
- $ wrap = entity_metadata_wrapper ($ entity_type , $ value );
524
+ $ fields [$ property ] = [
525
+ 'type ' => $ fieldType ,
526
+ 'description ' => isset ($ info ['description ' ]) ? $ info ['description ' ] : '' ,
527
+ 'resolve ' => function ($ value , $ args , $ context , ResolveInfo $ info ) use ($ entity_type , $ bundle , $ property ) {
528
+ if (isset ($ value ->wrapper )) {
529
+ $ wrap = $ value ->wrapper ();
530
+ } else {
531
+ $ wrap = entity_metadata_wrapper ($ entity_type , $ value );
532
+ }
533
+ $ items = $ wrap ->{$ property }->value ();
534
+ return $ items ;
531
535
}
532
- $ items = $ wrap ->{$ property }->value ();
533
- return $ items ;
536
+ ];
537
+ if (in_array ($ property , [
538
+ $ entity_keys ['id ' ],
539
+ $ entity_keys ['revision ' ]
540
+ ])) {
541
+ $ fields [$ property ]['type ' ] = Type::id ();
534
542
}
535
- ];
536
- if (in_array ($ property , [
537
- $ entity_keys ['id ' ],
538
- $ entity_keys ['revision ' ]
539
- ])) {
540
- $ fields [$ property ]['type ' ] = Type::id ();
541
543
}
542
544
}
543
545
@@ -581,7 +583,10 @@ public function getFields($entity_type, $bundle = '') {
581
583
break ;
582
584
case 'entityreference ' :
583
585
$ target_type = $ field_info ['settings ' ]['target_type ' ];
584
- $ target_bundles = array_values ($ field_info ['settings ' ]['handler_settings ' ]['target_bundles ' ]);
586
+ $ target_bundles = array ();
587
+ if (is_array ($ field_info ['settings ' ]['handler_settings ' ]['target_bundles ' ])) {
588
+ $ target_bundles = array_values ($ field_info ['settings ' ]['handler_settings ' ]['target_bundles ' ]);
589
+ }
585
590
if (empty ($ target_bundles )) {
586
591
$ target_bundles = array_keys ($ self ->getEntityInfo ($ target_type )['bundles ' ]);
587
592
}
@@ -746,4 +751,4 @@ public function drupalToGqlFieldType($drupalType, $context = []) {
746
751
return $ type ;
747
752
}
748
753
749
- }
754
+ }
0 commit comments