Skip to contents

Combines row objects from a caller-selected field in every result returned by fabric_graphql_paginate(). The explicit path is relative to each page's data field because GraphQL response shapes are schema-defined and cannot be inferred safely

Usage

fabric_graphql_collect(pages, path)

Arguments

pages

A fabric_graphql_pages result from fabric_graphql_paginate(). Requiring that result, rather than an unverified single response, lets the function enforce completion

path

Character path from each page's data field to the list of row objects, for example c("viewer", "products", "items")

Value

A fabric_graphql_rows tibble. Attributes complete, errors, page_count, and path retain collection metadata

Details

Scalar fields become ordinary tibble columns. Nested objects and arrays stay as list-columns and are never flattened. Fields introduced on later pages are added in first-seen order, with missing or GraphQL null scalar values represented by typed NA values when their type can be inferred. Exact integer strings returned by fabric_graphql_query() remain character data; finite numeric entries in the same field, including fractions, are promoted to character using text that recovers the received R value exactly. Fields containing only numeric values retain ordinary numeric columns

A successful result has class fabric_graphql_rows and reports completion, page count, path, and GraphQL errors in its printed header and attributes. Use attr(rows, "errors") to inspect partial GraphQL errors. If pagination stopped before next_cursor reported completion, including at max_pages, the function raises fabric_graphql_collection_error; its partial_data field contains the rows collected so far and is explicitly marked incomplete

Examples

if (FALSE) { # \dontrun{
# Discover the GraphQL API, then fetch every Products page
workspace <- fabric_workspaces()[[1L]]
api <- fabric_graphql_apis(workspace)[[1L]]
pages <- fabric_graphql_paginate(
  api,
  query = paste(
    "query Products($first: Int!, $after: String) {",
    "  products(first: $first, after: $after) {",
    "    items { id name details { category } }",
    "    hasNextPage endCursor",
    "  }",
    "}"
  ),
  variables = list(first = 100L, after = NULL),
  next_cursor = fabric_graphql_cursor("products")
)

# Combine nested item rows from every page into one tibble
rows <- fabric_graphql_collect(pages, c("products", "items"))
attr(rows, "complete")
attr(rows, "errors")
} # }