#' Get contents of a file
#'
#' @inheritParams get_description
#' @param path path to the file
#'
#' @return nothing interesting yet
#' @export
#'
#' @details
#' https://platform.github.community/t/query-repo-contents-with-graphql-api/1896
#' @examples
#' library("magrittr")
#' pof <- get_file(owner = "ropensci", repo = "roregistry",
#' branch = "master", path = "registry.json") %>%
#' jsonlite::toJSON()
get_file <- function(owner, repo, branch, path){
query <- paste0('query {
repository(name: "', repo,'", owner: "', owner,'") {
object(expression: "', branch, ':', path, '") {
... on Blob {
text
}
}
}
}')
qry <- ghql::Query$new()
qry$query('foobar', query)
create_client()$exec(qry$queries$foobar) %>%
jqr::jq(".data.repository.object.text")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.