File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 29
29
import strawberry
30
30
import typing
31
31
import ast
32
- from typing import Optional , List
32
+ import json
33
33
34
+ from typing import Optional , List , Any
34
35
from flask import Flask
35
36
from flask_cors import CORS
36
37
39
40
40
41
from strawberry .flask .views import GraphQLView
41
42
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
+
42
53
@strawberry .type
43
54
class RetrieveTransaction :
44
55
id : str
@@ -49,7 +60,7 @@ class RetrieveTransaction:
49
60
publicKey : str
50
61
operation : str
51
62
metadata : typing .Optional ["str" ]
52
- asset : strawberry . JSON
63
+ asset : JSONScalar
53
64
signerPublicKey : str
54
65
55
66
@strawberry .type
@@ -63,7 +74,7 @@ class PrepareAsset:
63
74
signerPublicKey : str
64
75
signerPrivateKey : str
65
76
recipientPublicKey : str
66
- asset : strawberry . JSON
77
+ asset : JSONScalar
67
78
68
79
@strawberry .type
69
80
class Query :
You can’t perform that action at this time.
0 commit comments