R/utilities.R

Defines functions build_query

Documented in build_query

#' Process a GraphQL query from COMPASS API
#'
#' @param query A string, the GraphQL query
#'
#' @return A list
#' @export
#'
#' @examples
#' my_query <- "{
#'         compendia {
#'             fullName,
#'             description
#'         }
#' }"
#' build_query(my_query)
build_query <- function(query){
  qry <- ghql::Query$new()
  qry$query('myquery', query)
  con <- ghql::GraphqlClient$new(url="http://compass.fmach.it/graphql/")
  RJSONIO::fromJSON(con$exec(qry$queries$myquery), nullValue=NA)$data
}
onertipaday/rcompass documentation built on Sept. 18, 2021, 5:13 p.m.