Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 Github comment. The code looks like this:
GeneratedList =
List.Generate(
() => [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]
)
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.
Update - and solution
According to this comment from Ben Gribaud, test function is also used for the initial result. With that in mind the working code looks like this:
GeneratedList =
List.Generate(
() => [res = getPage(queryName, query, operationName, [pagination = [first = 11]])],
each [res]<>null and [res][edges]<>null and List.Count([res][edges]) > 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]
)
Hi @alexbjorlig ,
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!
Best Regards
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
8 | |
7 | |
3 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
3 |