How do I implement a persisted GraphQL Paginated query that has Int parameters? | Community
Skip to main content
August 28, 2023
Solved

How do I implement a persisted GraphQL Paginated query that has Int parameters?

  • August 28, 2023
  • 3 replies
  • 1340 views

I currently have a persisted endpoint that is meant to allow for paging over a list of content fragments: 

 

/graphql/execute.json/xxx/getSomeContentFragmentPaginated;startRecord=0;numberOfRecords=3

 

 

The underlying GraphQL query looks something like this:

 

query getSomeContentFragmentPaginated($startRecord: Int, $numberOfRecords: Int)
{
     someContentFragmentList(offset: $startRecord, limit: $numberOfRecords) {
          items {
          ...

          }

     }

}

 

From the GraphQL Editor the query is ok - but when accessing it from the rest endpoint I get a casting error:

 

Variable 'startRecord' has an invalid value: Expected a value that can be converted to type 'Int' but it was a 'String' 

 

Any idea how I convert the incoming String value from the url to Int?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ArnoFourieEDG

This is a known issue apparently:

 

" SITES-15622: GraphQL - Issue with persisted queries with number & boolean parameters "

3 replies

ShaileshBassi
Community Advisor
Community Advisor
August 28, 2023

Hi @arnofourieedg I tried out hiting the persistent query within the browser and getting the desired result.

Can you share how are you creating the URL for hitting the endpoint URL?

Mahedi_Sabuj
Community Advisor
Community Advisor
August 28, 2023

Upon further investigation on both AEM Cloud (v2023.8.13099.20230810t160553z-230702) and AEM 6.5 SP18, found the "String to Int" casting error in the AEM Cloud. Interestingly, the SP18 version executed the persistent query flawlessly without encountering any errors. FYI @arnofourieedg 

Mahedi Sabuj
August 29, 2023

Update:  The query seems to work fine on 2023.7.12874 but not on 2023.8.13206...

 

Underlying issue seems to be regression testing. 😉

 

 

ArnoFourieEDGAuthorAccepted solution
August 30, 2023

This is a known issue apparently:

 

" SITES-15622: GraphQL - Issue with persisted queries with number & boolean parameters "