graphql-python / graphql-python/gql-next

load_introspection_from_server does not use custom headers

Offen
#25 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
78
Forks
6
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hello I'm trying to test gql but running ` gql run` returned
```

[...]

File "/home/rdebroiz/.virtualenvs/test_gql/lib/python3.7/site-packages/gql/utils_schema.py", line 22, in load_schema
introspection = load_introspection_from_file(uri) if os.path.isfile(uri) else load_introspection_from_server(uri)
File "/home/rdebroiz/.virtualenvs/test_gql/lib/python3.7/site-packages/gql/utils_schema.py", line 13, in load_introspection_from_server
raise Exception(f'Query failed to run by returning code of {request.status_code}. {query}')
Exception: Query failed to run by returning code of 401.

[...]
```

I suspect the cause is that the custom headers are not used to load the schema from the configured endpoint.

```python
def load_introspection_from_server(url):
query = get_introspection_query()
request = requests.post(url, json={'query': query})
if request.status_code == 200:
return request.json()['data']

raise Exception(f'Query failed to run by returning code of {request.status_code}. {query}')
```

Here is what my `.gql.json` look likes:
```json
{
"schema": "http://hasura:10004/v1alpha1/graphql",
"endpoint": "http://hasura:10004/v1alpha1/graphql",
"documents": "./**/*.graphql",
"custom_header": {
"x-hasura-admin-secret": "adminpw",
"x-hasura-access-key": "userpw"
}
}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.