-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_resolvers.py
31 lines (27 loc) · 947 Bytes
/
query_resolvers.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
from typing import Any, Dict, List, Optional
from tartiflette import Resolver
from model.main import ModelReadImageText
@Resolver("Query.image")
async def resolve_query_image(
parent: Optional[Any],
args: Dict[str, Any],
ctx: Dict[str, Any],
info: "ResolveInfo",
) -> str:
"""
Resolver for extract the text from an url image.
:param parent: initial value filled in to the engine `execute` method
:param args: computed arguments related to the field
:param ctx: context filled in at engine initialization
:param info: information related to the execution and field resolution
:type parent: Optional[Any]
:type args: Dict[str, Any]
:type ctx: Dict[str, Any]
:type info: ResolveInfo
:return: the text of the image
:rtype: str
"""
url_file = args['url']
read_image_text = ModelReadImageText()
result = read_image_text.evaluate(url_file)
return { 'text': result }