Skip to contents

GraphQL reports query errors in the body of an HTTP 200, as a top-level errors array, so a 2xx status is not enough to call a call successful.

Usage

graphql_error(res, source = "API")

Arguments

res

An envelope from post_json() or perform().

source

A friendly label for the service.

Value

The failing envelope, or NULL when the call genuinely succeeded.

Details

Returns an error envelope for either kind of failure, transport or query, so a GraphQL client collapses the two checks into one:

res <- post_json(url, body, source = "gnomAD")
bad <- graphql_error(res, "gnomAD")
if (!is.null(bad)) return(bad)

Examples

clean <- status_ok(data = list(data = list(gene = "BRCA1")), source = "G")
graphql_error(clean, "G")
#> NULL

queried <- status_ok(data = list(errors = list(list(message = "bad"))))
graphql_error(queried, "G")$status
#> [1] "error"