import json
import requests


def do_github_graphql_request(query, token, variables=None):
    """performs a requests.put with the correct headers for a GitHub request.

    see: https://developer.github.com/v4/

    Args:
    query: the graphQL query string (excluding the variables section)
    token: a GitHub API token string
    variables: a dict of key=value variables that will be sent with the query

    Returns:
    A requests.Response object
    """
    url = "https://api.github.com/graphql"
    headers = {
        "Authorization": "bearer " + token,
    }
    data = json.dumps({"query": query, "variables": json.dumps(variables)})
    return requests.post(url, headers=headers, data=data)