Skip to content

Commit 05ff317

Browse files
Update app.py
1 parent 34f89c9 commit 05ff317

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

app.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
import strawberry
3030
import typing
3131
import ast
32-
from typing import Optional, List
32+
import json
3333

34+
from typing import Optional, List, Any
3435
from flask import Flask
3536
from flask_cors import CORS
3637

@@ -39,6 +40,16 @@
3940

4041
from strawberry.flask.views import GraphQLView
4142

43+
@strawberry.scalar(description="Custom JSON scalar")
44+
class JSONScalar:
45+
@staticmethod
46+
def serialize(value: Any) -> Any:
47+
return value # Directly return the JSON object
48+
49+
@staticmethod
50+
def parse_value(value: Any) -> Any:
51+
return value # Accept JSON as is
52+
4253
@strawberry.type
4354
class RetrieveTransaction:
4455
id: str
@@ -49,7 +60,7 @@ class RetrieveTransaction:
4960
publicKey: str
5061
operation: str
5162
metadata: typing.Optional["str"]
52-
asset: strawberry.JSON
63+
asset: JSONScalar
5364
signerPublicKey: str
5465

5566
@strawberry.type
@@ -63,7 +74,7 @@ class PrepareAsset:
6374
signerPublicKey: str
6475
signerPrivateKey: str
6576
recipientPublicKey: str
66-
asset: strawberry.JSON
77+
asset: JSONScalar
6778

6879
@strawberry.type
6980
class Query:

0 commit comments

Comments
 (0)