graphql-python / graphql-python/graphene-sqlalchemy

MVC: support business logic layer

未關閉
#411 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
985
分支
223
PR 合併指標
30 天內沒有已合併 PR

描述

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)

貢獻指南

開啟貢獻指南

研究方向

從 SQLAlchemyObjectType 範例及其 resolve_name1 和 resolve_name2 進入點開始。檢視 Graphene-SQLAlchemy 目前如何處理 resolver,並判斷業務邏輯層是否適合此專案。完成的標準是針對支援此模式有一份達成共識的設計及記錄在案的範圍;該 issue 未列出任何檔案或測試。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
graphql, python, sqlalchemy
領域
api, backend-api-design
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
20/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。