Details
-
Improvement
-
Status: Done
-
Minor
-
Resolution: Done
-
None
-
None
-
None
Description
Provides a way to manipulate the String if the value of the returned field is String.
You may want to simply change the result value of the field returned by the query's result value. In the case of SQL, the return field can be prefixed with the string 'prefix'.
select concat('prefix_', label) as with_prefix from labels limit 2
I would like to implement the 'Directive' function provided by the GraphQL Spec as follows.
The script language used for the @transform directive is to use scala, which can be changed to a language that conforms to Javascript or other JVM ScriptEngine (JSR-223) specifications.
{ s2graph { user_id_test(id: 0) { s2graph_label_test_2(limit: 1) { item_id_test { id transformedId: id @transform(func: " (s: String) => s\"img_${s}_${s.toInt * 10}.jpg\" ") timestamp } } } } }
The result of the above query will be as follows.
You can see that the value of the 'transformedId' field has changed.
{ "data": { "s2graph": { "user_id_test": [ { "s2graph_label_test_2": [ { "item_id_test": { "id": "1", "transformedId": "img_1_10.jpg", "timestamp": 1527663919876 } } ] } ] } } }
Attachments
Issue Links
- links to