Skip to content

ApiNodeList.nextPage requests one extra page when there's no more results #309

@pawel-dabro

Description

@pawel-dabro

Which SDK version are you using?

v. 7

What's the issue?

ApiNodeList.nextPage requests one additional page even when it's at the last page of results currently.
Documentation in https://developers.facebook.com/docs/graph-api/using-graph-api/#paging states:

Stop paging when the next link no longer appears.

However, in that case ApiNodeList.nextPage falls back to cursor-based paging mechanism and only stops after retrieving an additional empty page with no cursor information.

Steps/Sample code to reproduce the issue

Use any graph edge that returns ApiNodeList like campaigns, that returns one or more pages of data

Observed Results:

  • What happened? This could be a description, log output, etc.

For N pages of data, there is N+1 requests beign made. One final request is made when there is no next link, which results in a response with empty data array and no paging section. Only after that paging stops, even though it is apparent from the lack of next page in Nth response that N+1th request is not necessary.

Nth request

2020-09-21 13:06:33.743 ========Start of API Call========
2020-09-21 13:06:33.743 Request:
2020-09-21 13:06:33.743 GET: https://graph.facebook.com/v7.0/act_.../campaigns?acce
ss_token=...&fields=id%2Cname&limit=25&after=QVFIUkhyNWtiM1JJLTk5WEhRaWZAFc0F...&appsecret_proof=...
2020-09-21 13:06:33.831 Response:
2020-09-21 13:06:33.831 {"data":[
<LAST PAGE OF DATA RETURNED HERE>
],"paging":{"cursors":{"before":"QVFIUkVES3hiV0tyUjQ...","after":"QVFIUlJReDdpSDlOcHlGeUYzemhqNDRsYV..."},
"previous":"https:\/\/graph.facebook.com\/v7.0\/act_...\/campaigns?access_token=...&fields=id\u00252Cname&limit=25&before=QVFIUkVES3hi..."}}
2020-09-21 13:06:33.831 ========End of API Call========

N+1th request

2020-09-21 13:06:33.836 ========Start of API Call========
2020-09-21 13:06:33.837 Request:
2020-09-21 13:06:33.837 GET: https://graph.facebook.com/v7.0/act_.../campaigns?acce
ss_token=...&appsecret_proof=...&after=QVFIUlJReDdpSDlOcHlGeUYzemhqNDRsYV...&fields=id%2Cname
2020-09-21 13:06:33.887 Response:
2020-09-21 13:06:33.887 {"data":[]}
2020-09-21 13:06:33.887 ========End of API Call========

Expected Results:

  • What did you expect to happen?

ApiNodeList.nextPage should not make the extra (N+1th) request for empty page when it knows from its current state that there was no more data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions