Skip to content

Commit 4c514b6

Browse files
committed
chore: fix the json object values and README
Signed-off-by: asararatnakar <[email protected]>
1 parent c844a26 commit 4c514b6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

transforms/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ For more on what `transforms` is and how it operates within the custom `@rest` d
88

99
- [filter](filter) shows how the response of a REST API can be filtered
1010
- [combineintostring](combineintostring) shows how a new field in the return type can be created by concatenating some other fields (like address parts into one address)
11-
- [jsonobjectToJsonarray](jsonobjectToJsonarray) shows how an array of data (say coords) can be converted into an object, `{"lat":, "lon",..}` so that it can be fed into some other system that requires data to be expressed that way
11+
- [jsonarrayToJsonobject](jsonarrayToJsonobject) shows how an array of data (say coords) can be converted into an object, `{"lat":, "lon",..}` so that it can be fed into some other system that requires data to be expressed that way
1212
- [jsonobjectToJsonarray](jsonobjectToJsonarray) shows how an object (typically where each key is an id of a record) can be converted into an array (e.g., `{"1":{"name": "john"}, "2": "jane"}` can be converted to `[{"id":"1", "name": "john"}, {"id":"2", name: "jane"}]`), so that it can then behave well for GraphQL processing.

transforms/jsonobjectToJsonarray/api.graphql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ type Query {
6161
# you could comment this out if you want to try setters instead
6262
{
6363
pathpattern: ["[]*"]
64-
editor: "jq:.[]|{id:.name,fullName:.value.name,age:.value.age}"
64+
editor: "jq:.[]|{id:.name,fullName:.value.fullName,age:.value.age}"
6565
}
6666
]
6767
# for the second transformation, you can use setters. Uncomment the next line and comment the second pathpattern line above to see how it operates.
68-
# setters: [{field: "id", path: "name"}, {field:"fullName", path: "value.age"}, {field:"age", path:"value.fullName"}]
68+
# for this to work change the return type from JSON to [Customer]
69+
# setters: [
70+
# { field: "id", path: "name" }
71+
# { field: "fullName", path: "value.fullName" }
72+
# { field: "age", path: "value.age" }
73+
# ]
6974
)
7075
}

0 commit comments

Comments
 (0)