Skip to content

Commit

Permalink
Merge pull request #1 from gqlmod/httpx
Browse files Browse the repository at this point in the history
Update for httpx
  • Loading branch information
AstraLuma authored Feb 15, 2021
2 parents f7f64ae + cc07870 commit 24b5403
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
7 changes: 3 additions & 4 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ test_task:
container:
image: python:3
setup_script:
# Until we get release stuff rolling
- pip install "git+https://github.com/gqlmod/gqlmod.git#egg=gqlmod"
- pip install .
- pip install --use-deprecated=legacy-resolver -e "git+https://github.com/gqlmod/gqlmod.git#egg=gqlmod[httpx]" .
- pip install pytest
test_script:
- python setup.py test
- pytest


flake8_task:
Expand Down
10 changes: 6 additions & 4 deletions gqlmod_cirrusci/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
"""
Provider for Cirrus CI's GraphQL API.
"""
from gqlmod.helpers.urllib import UrllibJsonProvider
from gqlmod.helpers.httpx import HttpxProvider


class CirrusCiProvider(UrllibJsonProvider):
class CirrusCiProvider(HttpxProvider):
endpoint = 'https://api.cirrus-ci.com/graphql'

def __init__(self, token=None):
self.token = token

def modify_request(self, req, variables):
def build_request(self, query, variables):
req = super().build_request(query, variables)
if self.token:
req.add_header('Authorization', f"Bearer {self.token}")
req.headers['Authorization'] = f"Bearer {self.token}"
return req
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ packages = find:
python_requires = >=3.7

install_requires =
gqlmod
gqlmod[httpx]~=0.9.0

setup_requires =
wheel
Expand Down

0 comments on commit 24b5403

Please sign in to comment.