Qlik Community

Qlik Sense Data Connectivity

Discussion board where members can learn more about Qlik Sense Data Connectivity.

Highlighted
Restless
New Contributor

Load data from GraphQL API with REST data connector

Hi everyone!

 

I'm using Qlik Sense desktop and load data from an API using the REST connector. I cannot load all data at once, so I need to use  pagination. The challenge here is, that GraphQL is used as query language. 

My question is: How can I page data I load from a GraphQL endpoint when I have to pass the page information in the body of a POST request?

 

Some background information:

I send a POST request to an API endpoint and specify the data I want to be returned. This specification happens in the body of the request in the form of an stringified JavaScript object (JSON).

The answer as well is a JSON string containing the information I requested. I am mainly interested in content, but also requested pageInfo which contains hasNextPage (Bool) and totalCount (int).

The URL of the endpoint is always the same, no data is passed via URL. Pagination information cannot be sent via header (only Authorization, content-type,accept-language).  

The request itself works. I just don't know how to handle the pagination.In each query, I have to manipulate the body of the request, changing the '0' to the number of the page I request.

 

mongoproductsearch(page:{page:0 size:10})

 

Size is limited to 10.000. Currently, I would haveto do ~50 requests. 

 

Thanks!

Robin

 

2019-03-19_13-39-05.pngGraphQL query and response

 

2019-03-19_13-43-11.pngREST Connector

 

2019-03-19_14-13-32.png

Labels (4)
1 Solution

Accepted Solutions
Support
Support

Re: Load data from GraphQL API with REST data connector

Hi Robin, you can modify body of a REST connection during script execution using WITH CONNECTION keyword, which provides a BODY parameter. See https://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/Connectors_REST/Load-R...
Vu Nguyen
If a post helps resolve your issue, please mark the answer as correct.
2 Replies
Support
Support

Re: Load data from GraphQL API with REST data connector

Hi Robin, you can modify body of a REST connection during script execution using WITH CONNECTION keyword, which provides a BODY parameter. See https://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/Connectors_REST/Load-R...
Vu Nguyen
If a post helps resolve your issue, please mark the answer as correct.
Restless
New Contributor

Re: Load data from GraphQL API with REST data connector

Hi, 

thanks, I was able to get it working using WITH CONNECTION.

This is my solution and what I learned on the way. In case someone stumbles upon this post:

  • I  use double quotes "" around the object property query and its value in the JSON string
  • In the query value itsself I use \"" to mask the quote

2019-04-04_12-16-25.png2019-04-04_12-17-16.png