-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (20 loc) · 671 Bytes
/
main.py
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
import strawberry
import typing
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
from cgan import generator_inference
@strawberry.type
class AddressPath:
path: str
@strawberry.input
class ImageClass:
class_number: int
@strawberry.type
class Mutation:
@strawberry.field
def generate_class_photo(self, image_cls: ImageClass) -> typing.List[AddressPath]:
return [AddressPath(path=path_value) for path_value in generator_inference(image_cls.class_number)]
schema = strawberry.Schema(query=AddressPath, mutation=Mutation)
graphql_app = GraphQLRouter(schema)
app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")