@@ -287,61 +287,6 @@ public function resolveResourceArgs(array $args, Operation $operation): array
287287 $ args [$ id ]['type ' ] = $ this ->typeConverter ->resolveType ($ arg ['type ' ]);
288288 }
289289
290- /*
291- * This is @experimental, read the comment on the parameterToObjectType function as additional information.
292- */
293- foreach ($ operation ->getParameters () ?? [] as $ parameter ) {
294- $ key = $ parameter ->getKey ();
295-
296- if (str_contains ($ key , ':property ' )) {
297- if (!($ filterId = $ parameter ->getFilter ()) || !$ this ->filterLocator ->has ($ filterId )) {
298- continue ;
299- }
300-
301- $ filter = $ this ->filterLocator ->get ($ filterId );
302- $ parsedKey = explode ('[:property] ' , $ key );
303- $ flattenFields = [];
304-
305- if ($ filter instanceof FilterInterface) {
306- foreach ($ filter ->getDescription ($ operation ->getClass ()) as $ name => $ value ) {
307- $ values = [];
308- parse_str ($ name , $ values );
309- if (isset ($ values [$ parsedKey [0 ]])) {
310- $ values = $ values [$ parsedKey [0 ]];
311- }
312-
313- $ name = key ($ values );
314- $ flattenFields [] = ['name ' => $ name , 'required ' => $ value ['required ' ] ?? null , 'description ' => $ value ['description ' ] ?? null , 'leafs ' => $ values [$ name ], 'type ' => $ value ['type ' ] ?? 'string ' ];
315- }
316-
317- $ args [$ parsedKey [0 ]] = $ this ->parameterToObjectType ($ flattenFields , $ parsedKey [0 ]);
318- }
319-
320- if ($ filter instanceof OpenApiParameterFilterInterface) {
321- foreach ($ filter ->getOpenApiParameters ($ parameter ) as $ value ) {
322- $ values = [];
323- parse_str ($ value ->getName (), $ values );
324- if (isset ($ values [$ parsedKey [0 ]])) {
325- $ values = $ values [$ parsedKey [0 ]];
326- }
327-
328- $ name = key ($ values );
329- $ flattenFields [] = ['name ' => $ name , 'required ' => $ value ->getRequired (), 'description ' => $ value ->getDescription (), 'leafs ' => $ values [$ name ], 'type ' => $ value ->getSchema ()['type ' ] ?? 'string ' ];
330- }
331-
332- $ args [$ parsedKey [0 ]] = $ this ->parameterToObjectType ($ flattenFields , $ parsedKey [0 ].$ operation ->getShortName ().$ operation ->getName ());
333- }
334-
335- continue ;
336- }
337-
338- $ args [$ key ] = ['type ' => GraphQLType::string ()];
339-
340- if ($ parameter ->getRequired ()) {
341- $ args [$ key ]['type ' ] = GraphQLType::nonNull ($ args [$ key ]['type ' ]);
342- }
343- }
344-
345290 return $ args ;
346291 }
347292
@@ -463,12 +408,15 @@ private function getResourceFieldConfiguration(?string $property, ?string $field
463408
464409 $ args = [];
465410
466- if (!$ input && !$ rootOperation instanceof Mutation && !$ rootOperation instanceof Subscription && !$ isStandardGraphqlType && $ isCollectionType ) {
467- if (!$ this ->isEnumClass ($ resourceClass ) && $ this ->pagination ->isGraphQlEnabled ($ resourceOperation )) {
468- $ args = $ this ->getGraphQlPaginationArgs ($ resourceOperation );
469- }
411+ if (!$ input && !$ rootOperation instanceof Mutation && !$ rootOperation instanceof Subscription && !$ isStandardGraphqlType ) {
412+ if ($ isCollectionType ) {
413+ if (!$ this ->isEnumClass ($ resourceClass ) && $ this ->pagination ->isGraphQlEnabled ($ resourceOperation )) {
414+ $ args = $ this ->getGraphQlPaginationArgs ($ resourceOperation );
415+ }
470416
471- $ args = $ this ->getFilterArgs ($ args , $ resourceClass , $ rootResource , $ resourceOperation , $ rootOperation , $ property , $ depth );
417+ $ args = $ this ->getFilterArgs ($ args , $ resourceClass , $ rootResource , $ resourceOperation , $ rootOperation , $ property , $ depth );
418+ $ args = $ this ->getParameterArgs ($ rootOperation , $ args );
419+ }
472420 }
473421
474422 if ($ isStandardGraphqlType || $ input ) {
@@ -491,6 +439,67 @@ private function getResourceFieldConfiguration(?string $property, ?string $field
491439 return null ;
492440 }
493441
442+ /*
443+ * This function is @experimental, read the comment on the parameterToObjectType function for additional information.
444+ * @experimental
445+ */
446+ private function getParameterArgs (Operation $ operation , array $ args = []): array
447+ {
448+ foreach ($ operation ->getParameters () ?? [] as $ parameter ) {
449+ $ key = $ parameter ->getKey ();
450+
451+ if (!str_contains ($ key , ':property ' )) {
452+ $ args [$ key ] = ['type ' => GraphQLType::string ()];
453+
454+ if ($ parameter ->getRequired ()) {
455+ $ args [$ key ]['type ' ] = GraphQLType::nonNull ($ args [$ key ]['type ' ]);
456+ }
457+
458+ continue ;
459+ }
460+
461+ if (!($ filterId = $ parameter ->getFilter ()) || !$ this ->filterLocator ->has ($ filterId )) {
462+ continue ;
463+ }
464+
465+ $ filter = $ this ->filterLocator ->get ($ filterId );
466+ $ parsedKey = explode ('[:property] ' , $ key );
467+ $ flattenFields = [];
468+
469+ if ($ filter instanceof FilterInterface) {
470+ foreach ($ filter ->getDescription ($ operation ->getClass ()) as $ name => $ value ) {
471+ $ values = [];
472+ parse_str ($ name , $ values );
473+ if (isset ($ values [$ parsedKey [0 ]])) {
474+ $ values = $ values [$ parsedKey [0 ]];
475+ }
476+
477+ $ name = key ($ values );
478+ $ flattenFields [] = ['name ' => $ name , 'required ' => $ value ['required ' ] ?? null , 'description ' => $ value ['description ' ] ?? null , 'leafs ' => $ values [$ name ], 'type ' => $ value ['type ' ] ?? 'string ' ];
479+ }
480+
481+ $ args [$ parsedKey [0 ]] = $ this ->parameterToObjectType ($ flattenFields , $ parsedKey [0 ]);
482+ }
483+
484+ if ($ filter instanceof OpenApiParameterFilterInterface) {
485+ foreach ($ filter ->getOpenApiParameters ($ parameter ) as $ value ) {
486+ $ values = [];
487+ parse_str ($ value ->getName (), $ values );
488+ if (isset ($ values [$ parsedKey [0 ]])) {
489+ $ values = $ values [$ parsedKey [0 ]];
490+ }
491+
492+ $ name = key ($ values );
493+ $ flattenFields [] = ['name ' => $ name , 'required ' => $ value ->getRequired (), 'description ' => $ value ->getDescription (), 'leafs ' => $ values [$ name ], 'type ' => $ value ->getSchema ()['type ' ] ?? 'string ' ];
494+ }
495+
496+ $ args [$ parsedKey [0 ]] = $ this ->parameterToObjectType ($ flattenFields , $ parsedKey [0 ].$ operation ->getShortName ().$ operation ->getName ());
497+ }
498+ }
499+
500+ return $ args ;
501+ }
502+
494503 private function getGraphQlPaginationArgs (Operation $ queryOperation ): array
495504 {
496505 $ paginationType = $ this ->pagination ->getGraphQlPaginationType ($ queryOperation );
0 commit comments