R/org_repo_forking.R

Defines functions org_repo_forking github_api_org_repo_forking

Documented in org_repo_forking

github_api_org_repo_forking = function(org) {
  org = graphql_escape(org)

  query = '
    query {
      organization(login: "{{{org}}}") {
        repositories(first: 100, after: <graphql_quote(cursor)>, privacy: PRIVATE) {
          totalCount
          pageInfo {
            hasNextPage
            endCursor
          }
          nodes {
            nameWithOwner
            forkingAllowed
            forkCount
          }
        }
      }
    }
  '

  query = whisker::whisker.render(query)

  github_api_v4_graphql_paginated(query, page_info = c("organization", "repositories"))
}


#' @rdname org_details
#' @export
#'
org_repo_forking = function(org) {
  arg_is_chr_scalar(org)

  pages = github_api_org_repo_forking(org)

  purrr::map_dfr(
    pages,
    function(page) {
      nodes = purrr::pluck(page, "data", "organization", "repositories", "nodes")

      tibble::tibble(
        repo          = purrr::map_chr(nodes, "nameWithOwner"),
        allow_forking = purrr::map_lgl(nodes, "forkingAllowed"),
        n_forks       = purrr::map_int(nodes, "forkCount")
      )
    }
  )
}

Try the ghclass package in your browser

Any scripts or data that you put into this service are public.

ghclass documentation built on Aug. 31, 2026, 5:08 p.m.