@@ -135,9 +135,13 @@ public function getLimit(string $resourceClass = null, string $operationName = n
135135 $ limit = $ resourceMetadata ->getCollectionOperationAttribute ($ operationName , 'pagination_items_per_page ' , $ limit , true );
136136 $ clientLimit = $ resourceMetadata ->getCollectionOperationAttribute ($ operationName , 'pagination_client_items_per_page ' , $ clientLimit , true );
137137 } else {
138- $ operation = $ resourceMetadata ->getOperation ($ operationName );
139- $ limit = $ operation ->getPaginationItemsPerPage () ?? $ limit ;
140- $ clientLimit = $ operation ->getPaginationClientItemsPerPage () ?? $ clientLimit ;
138+ try {
139+ $ operation = $ graphql ? $ resourceMetadata ->getGraphQlOperation ($ operationName ) : $ resourceMetadata ->getOperation ($ operationName );
140+ $ limit = $ operation ->getPaginationItemsPerPage () ?? $ limit ;
141+ $ clientLimit = $ operation ->getPaginationClientItemsPerPage () ?? $ clientLimit ;
142+ } catch (OperationNotFoundException $ e ) {
143+ // GraphQl operation may not exist
144+ }
141145 }
142146 }
143147
@@ -165,8 +169,12 @@ public function getLimit(string $resourceClass = null, string $operationName = n
165169 }
166170 $ maxItemsPerPage = $ resourceMetadata ->getCollectionOperationAttribute ($ operationName , 'pagination_maximum_items_per_page ' , $ maxItemsPerPage ?? $ this ->options ['maximum_items_per_page ' ], true );
167171 } elseif ($ resourceMetadata instanceof ResourceMetadataCollection) {
168- $ operation = $ resourceMetadata ->getOperation ($ operationName );
169- $ maxItemsPerPage = $ operation ->getPaginationMaximumItemsPerPage () ?? $ this ->options ['maximum_items_per_page ' ];
172+ try {
173+ $ operation = $ graphql ? $ resourceMetadata ->getGraphQlOperation ($ operationName ) : $ resourceMetadata ->getOperation ($ operationName );
174+ $ maxItemsPerPage = $ operation ->getPaginationMaximumItemsPerPage () ?? $ this ->options ['maximum_items_per_page ' ];
175+ } catch (OperationNotFoundException $ e ) {
176+ $ maxItemsPerPage = $ this ->options ['maximum_items_per_page ' ];
177+ }
170178 }
171179
172180 if (null !== $ maxItemsPerPage && $ limit > $ maxItemsPerPage ) {
@@ -263,9 +271,13 @@ private function getEnabled(array $context, string $resourceClass = null, string
263271 $ resourceMetadata = $ this ->resourceMetadataFactory ->create ($ resourceClass );
264272
265273 if ($ resourceMetadata instanceof ResourceMetadataCollection) {
266- $ operation = $ resourceMetadata ->getOperation ($ operationName );
267- $ enabled = $ partial ? $ operation ->getPaginationPartial () : $ operation ->getPaginationEnabled ();
268- $ clientEnabled = $ partial ? $ operation ->getPaginationClientPartial () : $ operation ->getPaginationClientEnabled ();
274+ try {
275+ $ operation = isset ($ context ['graphql_operation_name ' ]) ? $ resourceMetadata ->getGraphQlOperation ($ operationName ) : $ resourceMetadata ->getOperation ($ operationName );
276+ $ enabled = ($ partial ? $ operation ->getPaginationPartial () : $ operation ->getPaginationEnabled ()) ?? $ enabled ;
277+ $ clientEnabled = ($ partial ? $ operation ->getPaginationClientPartial () : $ operation ->getPaginationClientEnabled ()) ?? $ clientEnabled ;
278+ } catch (OperationNotFoundException $ e ) {
279+ // GraphQl operation may not exist
280+ }
269281 } else {
270282 $ enabled = $ resourceMetadata ->getCollectionOperationAttribute ($ operationName , $ partial ? 'pagination_partial ' : 'pagination_enabled ' , $ enabled , true );
271283 $ clientEnabled = $ resourceMetadata ->getCollectionOperationAttribute ($ operationName , $ partial ? 'pagination_client_partial ' : 'pagination_client_enabled ' , $ clientEnabled , true );
0 commit comments