rwxrob-dot/snippets/bash/curlgl
Rob Muhlestein 2ea0289e9f Rebase
2022-02-09 02:29:05 -05:00

19 lines
439 B
Plaintext

# curl a graphql query (change /tmp/gitstoken)
curlgl () {
declare uri="$1"
shift
declare q=$(argsorin "$@")
q=${q//\"/\\\"} # escape all the double quotes
q=${q//$'\n'/ } # force single line
q=${q//$'\t'/ } # remove random tabs
declare query='{"query": "'$q'"}'
curl -s -X POST \
-H "Authorization: Bearer $(</tmp/gitstoken)" \
-H 'Content-Type: application/json' \
-d "$query" "$uri" && echo
return $?
}