gh_gql {gh}R Documentation

A simple interface for the GitHub GraphQL API v4.

Description

See more about the GraphQL API here: https://developer.github.com/v4/

Usage

gh_gql(
  query,
  ...,
  .token = NULL,
  .destfile = NULL,
  .overwrite = FALSE,
  .api_url = NULL,
  .send_headers = NULL
)

Arguments

query

The GraphQL query, as a string.

...

Name-value pairs giving API parameters. Will be matched into endpoint placeholders, sent as query parameters in GET requests, and as a JSON body of POST requests. If there is only one unnamed parameter, and it is a raw vector, then it will not be JSON encoded, but sent as raw data, as is. This can be used for example to add assets to releases. Named NULL values are silently dropped, and named NA values trigger an error.

.token

Authentication token. Defaults to GITHUB_PAT or GITHUB_TOKEN environment variables, in this order if any is set. See gh_token() if you need more flexibility, e.g. different tokens for different GitHub Enterprise deployments.

.destfile

path to write response to disk. If NULL (default), response will be processed and returned as an object. If path is given, response will be written to disk in the form sent.

.overwrite

if .destfile is provided, whether to overwrite an existing file. Defaults to FALSE.

.api_url

Github API url (default: https://api.github.com). Used if endpoint just contains a path. Defaults to GITHUB_API_URL environment variable if set.

.send_headers

Named character vector of header field values (except Authorization, which is handled via .token). This can be used to override or augment the default User-Agent header: "https://github.com/r-lib/gh".

Details

Note: pagination and the .limit argument does not work currently, as pagination in the GraphQL API is different from the v3 API. If you need pagination with GraphQL, you'll need to do that manually.

See Also

gh() for the GitHub v3 API.

Examples


gh_gql("query { viewer { login }}")


[Package gh version 1.1.0 Index]