@@ -356,6 +356,8 @@ private function parameterToObjectType(array $flattenFields, string $name): Inpu
356356 if (isset ($ fields [$ key ])) {
357357 if ($ type instanceof ListOfType) {
358358 $ key .= '_list ' ;
359+ } elseif ($ fields [$ key ]['type ' ] instanceof InputObjectType && !$ type instanceof InputObjectType) {
360+ continue ;
359361 }
360362 }
361363
@@ -497,96 +499,67 @@ private function getResourceFieldConfiguration(?string $property, ?string $field
497499 */
498500 private function getParameterArgs (Operation $ operation , array $ args = []): array
499501 {
502+ $ groups = [];
503+
500504 foreach ($ operation ->getParameters () ?? [] as $ parameter ) {
501505 $ key = $ parameter ->getKey ();
502- $ property = $ parameter ->getProperty ();
503-
504- $ matchFound = false ;
505-
506- if ($ filter = $ this ->getFilterInstance ($ parameter ->getFilter ())) {
507- if ($ filter instanceof FilterInterface) {
508- foreach ($ filter ->getDescription ($ operation ->getClass ()) as $ name => $ value ) {
509- // Check if this description entry matches the current parameter's property
510- if ($ property && ($ value ['property ' ] ?? null ) === $ property ) {
511- $ matchFound = true ;
512-
513- $ suffix = '' ;
514- if (str_starts_with ($ name , $ property )) {
515- $ suffix = substr ($ name , \strlen ($ property ));
516- }
517506
518- $ argName = $ key .$ suffix ;
519-
520- $ type = \in_array ($ value ['type ' ] ?? 'string ' , TypeIdentifier::values (), true ) ? Type::builtin ($ value ['type ' ] ?? 'string ' ) : Type::object ($ value ['type ' ] ?? 'string ' );
521-
522- if (!($ value ['required ' ] ?? false )) {
523- $ type = Type::nullable ($ type );
507+ if (str_contains ($ key , '[ ' )) {
508+ $ key = str_replace ('. ' , $ this ->nestingSeparator , $ key );
509+ parse_str ($ key , $ values );
510+ $ rootKey = key ($ values );
511+
512+ $ leafs = $ values [$ rootKey ];
513+ $ name = key ($ leafs );
514+
515+ $ filterLeafs = [];
516+ if (($ filterId = $ parameter ->getFilter ()) && $ this ->filterLocator ->has ($ filterId )) {
517+ $ filter = $ this ->filterLocator ->get ($ filterId );
518+
519+ if ($ filter instanceof FilterInterface) {
520+ $ property = $ parameter ->getProperty () ?? $ name ;
521+ $ property = str_replace ('. ' , $ this ->nestingSeparator , $ property );
522+ $ description = $ filter ->getDescription ($ operation ->getClass ());
523+
524+ foreach ($ description as $ descKey => $ descValue ) {
525+ $ descKey = str_replace ('. ' , $ this ->nestingSeparator , $ descKey );
526+ parse_str ($ descKey , $ descValues );
527+ if (isset ($ descValues [$ property ]) && \is_array ($ descValues [$ property ])) {
528+ $ filterLeafs = array_merge ($ filterLeafs , $ descValues [$ property ]);
524529 }
525-
526- $ graphQlType = $ this ->getParameterType ($ type );
527-
528- parse_str ($ argName , $ parsed );
529- array_walk_recursive ($ parsed , static function (&$ v ) use ($ graphQlType ): void {
530- $ v = $ graphQlType ;
531- });
532-
533- $ args = $ this ->mergeFilterArgs ($ args , $ parsed , $ operation , $ key );
534- }
535- }
536- }
537-
538- if ($ filter instanceof OpenApiParameterFilterInterface) {
539- foreach ($ filter ->getOpenApiParameters ($ parameter ) as $ value ) {
540- $ matchFound = true ;
541- $ suffix = '' ;
542- if ($ property && str_starts_with ($ value ->getName (), $ property )) {
543- $ suffix = substr ($ value ->getName (), \strlen ($ property ));
544530 }
545-
546- $ argName = $ key .$ suffix ;
547- $ type = \in_array ($ value ->getSchema ()['type ' ] ?? 'string ' , TypeIdentifier::values (), true ) ? Type::builtin ($ value ->getSchema ()['type ' ] ?? 'string ' ) : Type::object ($ value ->getSchema ()['type ' ] ?? 'string ' );
548- if (!$ value ->getRequired ()) {
549- $ type = Type::nullable ($ type );
550- }
551- $ graphQlType = $ this ->getParameterType ($ type );
552- parse_str ($ argName , $ parsed );
553- array_walk_recursive ($ parsed , static function (&$ v ) use ($ graphQlType ): void {
554- $ v = $ graphQlType ;
555- });
556- $ args = $ this ->mergeFilterArgs ($ args , $ parsed , $ operation , $ key );
557531 }
558532 }
559- }
560533
561- if (!$ matchFound ) {
562- $ type = GraphQLType::string ();
563- if ($ parameter ->getNativeType ()) {
564- $ type = $ this ->getParameterType ($ parameter ->getNativeType ());
534+ if ($ filterLeafs ) {
535+ $ leafs [$ name ] = $ filterLeafs ;
565536 }
566537
567- $ arg = ['type ' => $ type ];
568-
569- if ($ parameter ->getRequired ()) {
570- $ arg ['type ' ] = GraphQLType::nonNull ($ arg ['type ' ]);
571- }
538+ $ groups [$ rootKey ][] = [
539+ 'name ' => $ name ,
540+ 'leafs ' => $ leafs [$ name ],
541+ 'required ' => $ parameter ->getRequired (),
542+ 'description ' => $ parameter ->getDescription (),
543+ 'type ' => 'string ' ,
544+ ];
545+ continue ;
546+ }
572547
573- if ($ parameter ->getDescription ()) {
574- $ arg ['description ' ] = $ parameter ->getDescription ();
575- }
548+ $ args [$ key ] = ['type ' => GraphQLType::string ()];
576549
577- if (str_contains ($ key , '[ ' )) {
578- parse_str ($ key , $ parsed );
579- array_walk_recursive ($ parsed , static function (&$ v ) use ($ arg ): void {
580- $ v = $ arg ['type ' ];
581- });
582- $ args = $ this ->mergeFilterArgs ($ args , $ parsed , $ operation , $ key );
583- } else {
584- $ args [$ key ] = $ arg ;
585- }
550+ if ($ parameter ->getRequired ()) {
551+ $ args [$ key ]['type ' ] = GraphQLType::nonNull ($ args [$ key ]['type ' ]);
586552 }
587553 }
588554
589- return $ this ->convertFilterArgsToTypes ($ args );
555+ foreach ($ groups as $ key => $ flattenFields ) {
556+ $ name = $ key .$ operation ->getShortName ().$ operation ->getName ();
557+ $ inputObject = $ this ->parameterToObjectType ($ flattenFields , $ name );
558+ $ this ->typesContainer ->set ($ name , $ inputObject );
559+ $ args [$ key ] = $ inputObject ;
560+ }
561+
562+ return $ args ;
590563 }
591564
592565 private function getGraphQlPaginationArgs (Operation $ queryOperation ): array
@@ -779,21 +752,4 @@ private function normalizePropertyName(string $property, string $resourceClass):
779752
780753 return $ this ->nameConverter ->normalize ($ property , $ resourceClass );
781754 }
782-
783- private function getFilterInstance (object |string |null $ filter ): ?FilterInterface
784- {
785- if (!$ filter ) {
786- return null ;
787- }
788-
789- if (\is_object ($ filter )) {
790- return $ filter ;
791- }
792-
793- if (!$ this ->filterLocator ->has ($ filter )) {
794- return null ;
795- }
796-
797- return $ this ->filterLocator ->get ($ filter );
798- }
799755}
0 commit comments