How to use the gql.transport.requests.RequestsHTTPTransport function in gql

To help you get started, we’ve selected a few gql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-python / gql / tests / test_transport.py View on Github external
def client():
    with vcr.use_cassette('tests/fixtures/vcr_cassettes/client.yaml'):
        request = requests.get(URL,
                            headers={
                                'Host': 'swapi.graphene-python.org',
                                'Accept': 'text/html',
                            })
        request.raise_for_status()
        csrf = request.cookies['csrftoken']

        return Client(
            transport=RequestsHTTPTransport(url=URL,
                                            cookies={"csrftoken": csrf},
                                            headers={'x-csrftoken':  csrf}),
            fetch_schema_from_transport=True
        )
github mavlink / MAVSDK / tools / generate_changelog.py View on Github external
def create_gql_client(token):
    transport = RequestsHTTPTransport(url='https://api.github.com/graphql', use_json=True)
    transport.headers = { "Authorization": "Bearer {}".format(token) }
    client = Client(transport=transport)

    return client
github seermedical / seer-py / seerpy / seerpy.py View on Github external
def graphql_client(party_id=None):
            connection_params = self.seer_auth.get_connection_parameters(party_id)
            return GQLClient(transport=RequestsHTTPTransport(**connection_params))
github FORTH-ICS-INSPIRE / artemis / frontend / webapp / core / modules.py View on Github external
def update_intended_process_states(self, name, running=False):
        try:
            access_token = create_access_token(identity=current_user)
            transport = RequestsHTTPTransport(
                url=GRAPHQL_URI,
                use_json=True,
                headers={
                    "Content-Type": "application/json; charset=utf-8",
                    "Authorization": "Bearer {}".format(access_token),
                },
                verify=False,
            )

            client = Client(
                retries=3, transport=transport, fetch_schema_from_transport=True
            )

            query = gql(intended_process_states_mutation)

            params = {"name": name, "running": running}
github FORTH-ICS-INSPIRE / artemis / monitor / core / utils / __init__.py View on Github external
def signal_loading(module, status=False):
    if GUI_ENABLED != "true":
        return
    try:

        transport = RequestsHTTPTransport(
            url=GRAPHQL_URI,
            use_json=True,
            headers={
                "Content-type": "application/json; charset=utf-8",
                "x-hasura-admin-secret": HASURA_GRAPHQL_ACCESS_KEY,
            },
            verify=False,
        )

        client = Client(
            retries=3, transport=transport, fetch_schema_from_transport=True
        )

        query = gql(PROCESS_STATES_LOADING_MUTATION)

        params = {"name": "{}%".format(module), "loading": status}
github willianantunes / flask-playground / flask_playground / services / github_graphql_api.py View on Github external
def _get_client() -> Client:
    if not (GITHUB_API_TOKEN and GITHUB_GRAPHQL_ENDPOINT):
        raise GithubGraphqlApiNotProperlyConfiguredException("Token and endpoint properties are required")
    # TODO I know it will create the same stuff all the time. Working in progress :)
    headers = {"Authorization": f"bearer {GITHUB_API_TOKEN}"}
    _transport = RequestsHTTPTransport(url=GITHUB_GRAPHQL_ENDPOINT, use_json=True, timeout=(5, 25), headers=headers)
    return Client(retries=3, transport=_transport, fetch_schema_from_transport=True)
github newrelic / newrelic-lambda-cli / newrelic_lambda_cli / api.py View on Github external
def __init__(self, account_id, api_key, region="us"):
        try:
            self.account_id = int(account_id)
        except ValueError:
            raise ValueError("Account ID must be an integer")

        self.api_key = api_key

        if region == "us":
            self.url = "https://api.newrelic.com/graphql"
        elif region == "eu":
            self.url = "https://api.eu.newrelic.com/graphql"
        else:
            raise ValueError("Region must be one of 'us' or 'eu'")

        transport = RequestsHTTPTransport(url=self.url, use_json=True)
        transport.headers = {"api-key": self.api_key}

        try:
            self.client = Client(transport=transport, fetch_schema_from_transport=True)
        except Exception:
            self.client = Client(transport=transport, fetch_schema_from_transport=False)
github graphql-python / gql / gql / transport / requests.py View on Github external
def __init__(self, url, auth=None, use_json=False, timeout=None, **kwargs):
        """
        :param url: The GraphQL URL
        :param auth: Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth
        :param use_json: Send request body as JSON instead of form-urlencoded
        :param timeout: Specifies a default timeout for requests (Default: None)
        """
        super(RequestsHTTPTransport, self).__init__(url, **kwargs)
        self.auth = auth
        self.default_timeout = timeout
        self.use_json = use_json