graphql-python / graphql-python/graphene-sqlalchemy

MVC: support business logic layer

Đang mở
#411 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
985
Fork
223
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

We have Model and View aka Node, but we lack a way to write code between them.

```Python
class PetBusinessLogic:
def __init__(self, pet):
self.pet = pet

@property
def name1(self):
return self.pet.name + "!"

@property
def name2(self):
return self.pet.name + "!"

class Pet(SQLAlchemyObjectType):
class Meta:
model = PetModel
name = "Pet"
interfaces = (relay.Node,)
batching = True

def resolve_name1(node, info):
# write here application logic code for a large project is not good idea.
# so we need some controller aka PetBusinessLogic
return PetBusinessLogic(node).name1 # DRY and I would like to initialize it once

def resolve_name2(node, info):
return PetBusinessLogic(node).name2 # DRY and I would like to initialize it once
```

Any suggestions for this design problem?
*(put this PetBusinessLogic into model is also bad idea)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.