Microservices #2803
Replies: 2 comments
-
graph Company graph Orders @classmethod only one field and only the ID is passed through the keys. an attempt to pass other fields causes the error " "Unable to resolve reference for <class 'query_schemas.Order'>"" |
Beta Was this translation helpful? Give feedback.
-
please format the codes. At current stage it looks horrible ( and it probably reduces your chance of getting help ) |
Beta Was this translation helpful? Give feedback.
-
Вопрос, как наладить взаимодействие между сервисами. Проблема в том, что мне нужно перенаправить запрос на другой сервер, получить ответ и привести его к стравберри схемам.
Каким образом в Сервисе предусмотрена возможно создавать микросервисы?
сервисы написаны на разных языках
URL = "http://192.168.50.30:3002/graphql"
query = """query {sys_users {
id
name
roles{
id
name
}
avatar}}"""
async def get_user() -> list[Manager]:
async with httpx.AsyncClient() as client:
req = await client.request(method='post', url=URL, json={'query': query},
headers={"allow_origins": "allow_origins", "access-control-allow-origin": "*"})
return [Manager(**i) for i in req.json()['data']['sys_users']]
unpacking with ** does not allow you to look into the depths of the answer. And the schemes accept only the stove keyword arguments. At the same time, it is also unrealistic to transfer the list to another resolver, because this is prohibited by the service. Also, if you use another resolver in the schema field, the Resolver is initiated at an incomprehensible moment. Also, the scheme ceases to pay attention to the field in which the resolver is specified
@strawberry.type
class UserRole:
id: int
name: str
@strawberry.type
class Manager:
id: strawberry.ID | None = None
name: str | None = None
avatar: str | None = None
surname: str | None = None
patronymic: str | None = None
email: str | None = None
roles: List[UserRole] = strawberry.field(resolver=resolver())
Beta Was this translation helpful? Give feedback.
All reactions