according to examples from https://cli.github.com/manual/gh_api:
# print only specific fields from the response
$ gh api repos/{owner}/{repo}/issues --jq '.[].title'
GitHUb CLI (gh) can use the '-q' or '--jq' argument followed by a query string to select values from the response and e.g. display only certain fields.
I'd like to do a similar thing using either CURL, postman or JavaScript fetch().
So my question is: is the --jq
query string sent (somehow) by gh
CLI as part of an http request and processed on the server (to reduce the amount of data in the response), or is it only applied on the client side as post-processing of the data received ?
And if that query string can be passed to and processed on the server, how should it be specified if I need to make the request not with gh
but with curl
, postman
or javascript fetch()
method?
I fear the processing is actually done on the client, meaning the http response will always provide the full data...
Can someone confirm this? Thanks!
CodePudding user response:
The response is filtered on the client. You can verify yourself by taking a look at the source code:
if opts.FilterOutput != "" && serverError == "" { // TODO: reuse parsed query across pagination invocations err = jq.Evaluate(responseBody, bodyWriter, opts.FilterOutput) if err != nil { return } }
CodePudding user response:
curl, postman, fetch
Your goal is to make an HTTP Request, not use the gh
CLI.
GitHub's GraphQL API is what you seek:
To create integrations, retrieve data, and automate your workflows, use the GitHub GraphQL API. The GitHub GraphQL API offers more precise and flexible queries than the GitHub REST API.
GraphQL only returns the data requested. The data is "processed" on the API server and then sent to the client.