Skip to content

Instantly share code, notes, and snippets.

@kyanny
Last active October 26, 2021 18:09
Show Gist options
  • Save kyanny/7691b84209689d8c5ec2b4fae19a7ddc to your computer and use it in GitHub Desktop.
Save kyanny/7691b84209689d8c5ec2b4fae19a7ddc to your computer and use it in GitHub Desktop.
Call GraphQL API with curl.
#!/bin/bash
# Usage: bash graphql.sh < query.txt
query=$(cat - | sed -e 's/"/\\"/g' | tr -d '\n')
cat <<EOM> query.json
{"query":"$query"}
EOM
curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/graphql -d @query.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment