graphql-python / graphql-python/gql-next
load_introspection_from_server does not use custom headers
- Ngôn ngữ chính
- Python
- Star
- 78
- Fork
- 6
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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"
}
}
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với load_introspection_from_server trong utils_schema.py và theo dõi cách quá trình tải schema nhận các giá trị custom_header đã cấu hình. Kiểm tra đường dẫn của yêu cầu introspection đã xác thực và mọi kiểm thử liên quan hoặc cấu hình lệnh. Hoàn tất khi các header đã cấu hình được sử dụng lúc tải schema và trường hợp 401 được báo cáo đã được bao phủ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- graphql, python
- Lĩnh vực
- api, authentication
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100