<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to make List.Generate work with cursor based pagination in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/How-to-make-List-Generate-work-with-cursor-based-pagination/m-p/1826182#M29308</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/204812"&gt;@alexbjorlig&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for sharing your solution here, it will help the others in the community find the solution easily if they face the same problem with yours. Much appreciated!&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Thu, 06 May 2021 02:53:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-05-06T02:53:31Z</dc:date>
    <item>
      <title>How to make List.Generate work with cursor based pagination</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-make-List-Generate-work-with-cursor-based-pagination/m-p/1821561#M29281</link>
      <description>&lt;P&gt;I'm developing a custom power bi connector consuming a GraphQl API, and my objective is to use the List.Generate to support cursor based pagination. My code is inspired by this &lt;A href="https://gist.github.com/petrsvihlik/cc34a6cf1882d515139c5b27f37cf99e#gistcomment-3498436" target="_self"&gt;Github comment&lt;/A&gt;. The code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;GeneratedList =
            List.Generate(
                () =&amp;gt; [res = getPage(queryName, query, operationName, [pagination = [first = 100]])],
                each Comparer.Equals(Comparer.FromCulture("en-us"), [res][hasNextPage], true ),
                each [ res = getPage(queryName, query, operationName, [pagination = [first = 100, after = [res][endCursor]]] ) ],
                each [res][edges]
            )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above works if the initial page has more than 100 items. But if all items can be returned in the initial call, then it does not work, an empty list is returned. Why is this the case? I checked the queries that are returned from the API and they seem to work perfect with hasNextPage property.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Update - and solution&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;According to &lt;A href="https://gist.github.com/petrsvihlik/cc34a6cf1882d515139c5b27f37cf99e#gistcomment-3729157" target="_self"&gt;this&lt;/A&gt; comment from&amp;nbsp;Ben Gribaud, test function is also used for the initial result. With that in mind the working code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        GeneratedList =
            List.Generate(
                () =&amp;gt; [res = getPage(queryName, query, operationName, [pagination = [first = 11]])],
                each [res]&amp;lt;&amp;gt;null and [res][edges]&amp;lt;&amp;gt;null and List.Count([res][edges]) &amp;gt; 0,
                each [ res = if Comparer.Equals(Comparer.FromCulture("en-us"), [res][hasNextPage], false ) then null else getPage(queryName, query, operationName, [pagination = [first = 23, after = [res][endCursor]]] ) ],
                each [res][edges]
            )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 08:41:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-make-List-Generate-work-with-cursor-based-pagination/m-p/1821561#M29281</guid>
      <dc:creator>alexbjorlig</dc:creator>
      <dc:date>2021-05-04T08:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to make List.Generate work with cursor based pagination</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-make-List-Generate-work-with-cursor-based-pagination/m-p/1826182#M29308</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/204812"&gt;@alexbjorlig&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for sharing your solution here, it will help the others in the community find the solution easily if they face the same problem with yours. Much appreciated!&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 02:53:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-make-List-Generate-work-with-cursor-based-pagination/m-p/1826182#M29308</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-05-06T02:53:31Z</dc:date>
    </item>
  </channel>
</rss>

