There's some way to set the `source` field param for nested fields?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với graphene/types/field.py tại đoạn mã phân giải source được tham chiếu và theo dõi cách các trường DjangoObjectType sử dụng giá trị source. So sánh ví dụ actor__login với phương án thay thế hiện tại sử dụng resolver tùy chỉnh; được coi là hoàn tất khi hành vi quan hệ lồng nhau như dự kiến được hỗ trợ hoặc khi giới hạn và cách tiếp cận resolver được mong đợi được ghi lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Context
I'm currently trying to set my model user User subfield user.actor.id as field source of my DjangoObjectType.
This happens because there's other kind of users within the application like an Organization or even a Bot (all of them are actors).
Example
Lets define a custom Type:
class User(DjangoObjectType):
class Meta:
model = UserModel
exclude = ['actor']
filter_fields = ['actor__login']
interfaces = [graphene.relay.Node]
skip_registry = True
# The login field is originated from `actor` relationship, not from the user model itself.
# It doesn't work, actor__login is interpreted as user field [user.actor__login] not [user.actor.login].
login = graphene.Field(graphene.String, source='actor__login')
# ...
In the example above I define the login field source as source='actor__login' but I saw that here we're using getattr function to resolve the source so it's currently impossible to set the field without defining a custom resolver.
I would like to know if there's an alternative solution to select a subfield like the example or we're forced to create a custom resolver by using the resolver=lambda _, __: ... arg or the class method declaration.
Thanks for the hard work and the library!
- 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 ·
-
✨ enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
graphql-python/graphene#1600 ·
-
Inaccurate Float-to-Decimal Conversion in `parse_value` of `Decimal` `Scalar`Có thể đã có người làm @mak626 đã nhận 608 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 ·
Tất cả issue của graphql-python/graphene
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
vllm-project/vllm#61131 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kubernetes-client/python#2735 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
desktop help wanted test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Broken links found in docsĐang mởdocs pydanty:is-working
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
pydantic/pydantic-ai#10113 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Tutorial unit test leaks sample data into tutorial doctestCó thể đã có người làm @Gambit-Checkmate đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100