Support lazy type references everywhere
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Review graphene/relay/connection.py around the node type checks and name handling, and graphene/types/objecttype.py around fields construction. Use PR #1599 as the Union precedent. Done means lazy string or callable references work consistently for Connection node types, Union members, and ObjectType or Interface interfaces.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
Currently, Graphene supports lazy type references (a string or a callable) in fields, input fields, and arguments. But there are other places where types are coupled that don't support it. From what I can tell, it's these cases:
- Node types of a
relay.Connection - Member types of a
Union - Interfaces of an
ObjectTypeor anotherInterface
Lazy references are useful for modelling schemas with circular dependencies across multiple Python modules without creating circular imports. But they're also useful for non-static schemas, which you might have when some relationships depend on configuration such as feature flags that aren't available at import time. For example, it's possible to do this:
class SomeType(ObjectType):
field = Field(lambda: OneType if CONFIG.get_feature_flag() else AnotherType)
but we can't have this:
class SomeUnion(Union):
class Meta:
types = (lambda: OneType if CONFIG.get_feature_flag() else AnotherType, ...)
Overall, it's a bit unintuitive that lazy references are allowed in some places but not others.
Describe the solution you'd like
Support lazy type references consistently across all type declarations, including in the three cases described above.
Describe alternatives you've considered
For circular imports, it's usually possible to break dependencies elsewhere in the chain where lazy references are already supported. Though there may be some more contrived cases that only involve the relationships described above, where this wouldn't be possible.
For dynamic schema parts, you could define all schema components at runtime rather than statically, but in practice I think the static approach is cleaner in most cases and makes it easier to distribute schema components across multiple modules.
Additional context
I don't expect the changes to be huge, they should be non-breaking, and I'm happy to contribute them if people find this useful.
- I've already prepared a PR for adding support to Union types: #1599
- Supporting node types for
Connectionshould be easier. The node construction already supports lazy references, we'd just need to remove the hard-coded instance check and handle cases where the name isn't available here. - Interfaces are probably the biggest change since that will require the entire fields construction here to be moved to a property to be resolved lazily. Even then, it's conceptually very similar to the
Unionchange above.
- Ngôn ngữ chính
- Python
- Star
- 8.2k
- Fork
- 822
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của graphql-python/graphene
-
Tutorial mistakesĐang mở🐛 bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
graphql-python/graphene#1389 · 5 bình luận · 2 reaction ·
-
Support OneOf input object typesĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
graphql-python/graphene#1606 ·
-
Python 3.14 supportĐang mở✨ enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 38/100
graphql-python/graphene#1601 · 2 bình luận ·
-
Inaccurate Float-to-Decimal Conversion in `parse_value` of `Decimal` `Scalar`Có thể đã có người làm @mak626 đã nhận 607 ngày trước. Đang mở🐛 bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
graphql-python/graphene#1593 ·
-
🐛 bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
graphql-python/graphene#1592 ·
Tất cả issue của graphql-python/graphene
Issue tương tự
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
hatchet-dev/hatchet#5179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update Python support to 3.15Đang mởpython-version
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug javascript P2-medium python release:v3.1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
adrirubio/claude-deck#546 ·
Maintainer thường phản hồi trong vòng 1 ngày