0xPlaygrounds / 0xPlaygrounds/subgrounds
Subgraphs with `_type` fail at auto-select
- Ngôn ngữ chính
- Python
- Star
- 73
- Fork
- 12
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
**Describe the bug**
With `Subgrounds` feature of auto select when given a top-level field or entity, it automatically grabs every scalar field + every object field's id. This will clash causing non-sense errors if a subgraph has a rare `_type` or other variable that exists on the `FieldPath` object.
**To Reproduce**
Steps to reproduce the behavior:
1. Test out this snippet of code with the latest subgrounds
```py
from subgrounds import Subgrounds
sg = Subgrounds()
aave_v2 = sg.load_subgraph("https://api.thegraph.com/subgraphs/name/messari/aave-v2-ethereum")
sg.query_df(aave_v2.Query.markets)
```
2. Observe an absurd stack limit error dealing with crazy recursion.
**Expected behavior**
There should be no clash and the data should be accessed
**Python version (please complete the following information):**
- Python 3.11 w/ Subgrounds 1.6.0
**Additional context**
Potential Solutions:
a) we rename all internal variables of `FieldPath` (and `Subgraph`) to start with `__` to enable python's name-mangling
b) we replace `__getattribute__` with `__getattr__` so that internal vars don't go thru a special access layer
- this would enforce the use of `._select` if there _was_ a name clash with a field
Doing both a) **and** b) could be ideal since the name-mangle will reduce collisions and the `__getattr__` would ensure consistent and crashless behavior in edge cases.
Likely, the hardest part to fixing this issue is fixing all of the test cases as well.
Hướng dẫn đóng góp
Hướng nghiên cứu
The issue is in the FieldPath and Subgraph classes where internal variable names like `_type` clash with subgraph fields. Start by examining the `__getattribute__` method in these classes. Look at the auto-select logic that grabs scalar fields. The fix involves renaming internal variables to use double underscores for name mangling and/or switching to `__getattr__`. Run existing tests to ensure changes don't break functionality, focusing on tests related to auto-select and field access.
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, backend, data
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 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
- 40/100