-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrawberry_types.py
More file actions
46 lines (38 loc) · 916 Bytes
/
Copy pathstrawberry_types.py
File metadata and controls
46 lines (38 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from typing import List
import strawberry
@strawberry.type
class Date:
year: int
month: int
day: int
@strawberry.type
class AdditionalInfo:
status: str
birth_date: Date
@strawberry.type
class UserMeta:
email: str
name: str
additional_info: AdditionalInfo
@strawberry.type
class Query:
@strawberry.field
def users(self, year: int) -> List[UserMeta]:
return list(filter(lambda u: u.additional_info.birth_date.year == year, [
UserMeta(
"hello@world.ru",
"Mike",
AdditionalInfo(
"I am a hero",
Date(2001, 1, 1)
)
),
UserMeta(
"hi@world.ru",
"Pol",
AdditionalInfo(
"DevOps",
Date(1001, 1, 1)
)
),
]))