Union types in connections: 'UnionOptions' object has no attribute 'model'
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu với SQLAlchemyConnectionField.wrap_resolve() và thuộc tính model của nó, sau đó tái hiện truy vấn được báo cáo bằng một union của Graphene gồm các lớp SQLAlchemyObjectType. Theo dõi cách dữ liệu _meta của union được truyền đến connection resolver; cần định nghĩa cách xử lý các connection có nhiều model nền tảng mà không gặp lỗi UnionOptions.model đã được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Are there plans to add support for union types in connections? I have a setup like the following:
class Cat(SQLAlchemyObjectType):
class Meta:
model = CatModel
interfaces = (relay.Node,)
class Dog(SQLAlchemyObjectType):
class Meta:
model = DogModel
interfaces = (relay.Node,)
class Animal(graphene.Union):
class Meta:
types = (Cat, Dog)
class Query(graphene.ObjectType):
animals = SQLAlchemyConnectionField(Animal)
and when I try to query for animals, I get the error: 'UnionOptions' object has no attribute 'model'.
I traced this back to the self.model call in wrap_resolve():
def wrap_resolve(self, parent_resolver):
return partial(
self.connection_resolver,
parent_resolver,
get_nullable_type(self.type),
self.model,
)
def model(self):
return get_nullable_type(self.type)._meta.node._meta.model
When the type is a union, get_nullable_type(self.type)._meta.node._meta returns the union class (in this case Animal). In order to get a model from that, we have to drill down into its types (e.g. get_nullable_type(self.type)._meta.node._meta.types[0]._meta.model) but because it's a union, it will contain multiple models.
Any ideas how to get around this?
- Ngôn ngữ chính
- Python
- Star
- 985
- Fork
- 224
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
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-sqlalchemy
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
graphql-python/graphene-sqlalchemy#422 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
graphql-python/graphene-sqlalchemy#419 · 3 bình luận ·
Tất cả issue của graphql-python/graphene-sqlalchemy
Issue tương tự
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
[Feature] 奇物选择添加优先级 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
syfoud/Simulated_Scepter#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Giskard-AI/giskard-oss#2840 · 1 bình luận ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Đang mởarea: repo bug perceived difficulty: 2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·