@@ -75,27 +75,32 @@ public function create(string $className, string $typeName): Type
7575 */
7676 private function getGroupType (string $ className , string $ typeName ): InputObjectType
7777 {
78+ $ fields = [
79+ [
80+ 'name ' => 'groupLogic ' ,
81+ 'type ' => $ this ->types ->get ('LogicalOperator ' ),
82+ 'description ' => 'The logic operator to be used to append this group ' ,
83+ 'defaultValue ' => 'AND ' ,
84+ ],
85+ [
86+ 'name ' => 'conditionsLogic ' ,
87+ 'type ' => $ this ->types ->get ('LogicalOperator ' ),
88+ 'description ' => 'The logic operator to be used within all conditions in this group ' ,
89+ 'defaultValue ' => 'AND ' ,
90+ ],
91+ $ this ->filterGroupConditionTypeFactory ->getField ($ className ),
92+ ];
93+
94+ // Only create join type, if there is anything to join on
95+ if ($ this ->filterGroupJoinTypeFactory ->canCreate ($ className )) {
96+ $ fields [] = $ this ->filterGroupJoinTypeFactory ->getField ($ className );
97+ }
98+
7899 $ conditionType = new InputObjectType ([
79100 'name ' => $ typeName . 'Group ' ,
80101 'description ' => 'Specify a set of joins and conditions to filter ` ' . Utils::getTypeName ($ className ) . '` ' ,
81- 'fields ' => [
82- [
83- 'name ' => 'groupLogic ' ,
84- 'type ' => $ this ->types ->get ('LogicalOperator ' ),
85- 'description ' => 'The logic operator to be used to append this group ' ,
86- 'defaultValue ' => 'AND ' ,
87- ],
88- [
89- 'name ' => 'conditionsLogic ' ,
90- 'type ' => $ this ->types ->get ('LogicalOperator ' ),
91- 'description ' => 'The logic operator to be used within all conditions in this group ' ,
92- 'defaultValue ' => 'AND ' ,
93- ],
94- $ this ->filterGroupJoinTypeFactory ->getField ($ className ),
95- $ this ->filterGroupConditionTypeFactory ->getField ($ className ),
96- ],
102+ 'fields ' => $ fields ,
97103 ]);
98-
99104 $ this ->types ->registerInstance ($ conditionType );
100105
101106 return $ conditionType ;
0 commit comments