Interfaces are ignored when define Mutation.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu trong graphene/types/mutation.py tại init_subclass_with_meta và tái hiện ví dụ CreatePlan đã được báo cáo. Bản sửa được hoàn tất khi việc định nghĩa một mutation có interfaces giữ lại các trường của interface trong output của nó thay vì loại bỏ chúng khi không cung cấp output tường minh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello.
First of all, thanks for all graphene developers and contributors.
- What is the current behavior?
Interface is ignored when define mutation. This is my code.
class CreatePlan(Mutation):
class Meta:
interfaces = (PlanInterface, )
class Arguments:
name = String(required=True)
comment = String(default_value='')
goal = String(required=True)
start_date = DateTime(required=True)
end_date = DateTime(required=True)
def mutate(parent, info, **kwargs):
~~~
# this raises AssertionError:
# CreatePlan fields must be a mapping (dict / OrderedDict)
# with field names as keys or a function which returns such a mapping.
-
What is the expected behavior?
I think Mutation should includes all interfaces and fields together. -
Please tell us about your environment:
Here is my environment.- Version: 2.1.9
- Platform: Mac OS
-
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
I think removing just a line can resolve this problem.
branch v2, graphene/types/mutation.py line 69
@classmethod
def __init_subclass_with_meta__(
cls,
interfaces=(),
resolver=None,
output=None,
arguments=None,
_meta=None,
**options
):
if not _meta:
_meta = MutationOptions(cls)
output = output or getattr(cls, "Output", None)
fields = {}
for interface in interfaces:
assert issubclass(interface, Interface), (
'All interfaces of {} must be a subclass of Interface. Received "{}".'
).format(cls.__name__, interface)
fields.update(interface._meta.fields)
if not output:
# If output is defined, we don't need to get the fields
fields = OrderedDict(). # This ignores interfaces. Remove this.
for base in reversed(cls.__mro__):
fields.update(yank_fields_from_attrs(base.__dict__, _as=Field))
output = cls
Also, I found same problem on master branch.
@classmethod
def __init_subclass_with_meta__(
cls,
interfaces=(),
resolver=None,
output=None,
arguments=None,
_meta=None,
**options,
):
if not _meta:
_meta = MutationOptions(cls)
output = output or getattr(cls, "Output", None)
fields = {}
for interface in interfaces:
assert issubclass(
interface, Interface
), f'All interfaces of {cls.__name__} must be a subclass of Interface. Received "{interface}".'
fields.update(interface._meta.fields)
if not output:
# If output is defined, we don't need to get the fields
fields = {}. # This ignores interfaces. Remove this.
for base in reversed(cls.__mro__):
fields.update(yank_fields_from_attrs(base.__dict__, _as=Field))
output = cls
- 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 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 ·
Tất cả issue của graphql-python/graphene
Issue tương tự
-
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
-
area: desktop area: website priority: P2 type: feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
appandflow/stim#3411 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 88/100
baptistehamon/lsapy#185 ·
Maintainer thường phản hồi trong vòng 1 ngày