Locate pagination information in a GraphQL result
Source:R/fabric_graphql_query.R
fabric_graphql_cursor.RdCreates the next_cursor function used by fabric_graphql_paginate() for the
common hasNextPage and endCursor pagination fields
Arguments
- path
Character path from the result's
datafield to a connection object, for example"products"orc("viewer", "products"). This is the parent object that contains the pagination fields, not theitemsfield- has_next
Name of the logical connection field indicating another page. Fabric commonly uses
"hasNextPage"- end_cursor
Name of the connection field containing the opaque cursor Fabric commonly uses
"endCursor"
Value
A function suitable for next_cursor in
fabric_graphql_paginate(). For each page it returns the cursor when
has_next is true, otherwise NULL
Examples
# Build a reusable extractor for a GraphQL connection named "products"
next_cursor <- fabric_graphql_cursor("products")
# This small local result shows the response shape expected by the extractor
page <- structure(
list(data = list(products = list(
hasNextPage = TRUE,
endCursor = "opaque-cursor"
))),
class = c("fabric_graphql_result", "list")
)
# TRUE plus a cursor tells the paginator to request another page
next_cursor(page)
#> [1] "opaque-cursor"