Skip to content

Instantly share code, notes, and snippets.

@kyanny
Last active October 26, 2021 18:09

Revisions

  1. kyanny revised this gist Oct 26, 2021. No changes.
  2. kyanny revised this gist Oct 26, 2021. 1 changed file with 2 additions and 10 deletions.
    12 changes: 2 additions & 10 deletions graphql.sh
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,7 @@
    #!/bin/bash
    # Usage: bash graphql.sh < query.txt

    cat > query.txt <<EOM
    {
    license(key:"mit") {
    name
    description
    }
    }
    EOM

    query=$(cat query.txt | sed -e 's/"/\\"/g' | tr -d '\n')
    query=$(cat - | sed -e 's/"/\\"/g' | tr -d '\n')

    cat <<EOM> query.json
    {"query":"$query"}
  3. kyanny created this gist Oct 26, 2021.
    18 changes: 18 additions & 0 deletions graphql.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    cat > query.txt <<EOM
    {
    license(key:"mit") {
    name
    description
    }
    }
    EOM

    query=$(cat query.txt | 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