Skip to content

Commit 15b26fb

Browse files
Merge pull request #67 from stepzen-dev/fix_fieldval
chore: fix the json object values and README
2 parents c844a26 + 99b3bd7 commit 15b26fb

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
.env
2+
.env
3+
.vscode
4+

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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ 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
]
67+
6768
# 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"}]
69+
# In order to make this to work, change the return type from JSON to [Customer].
70+
71+
# setters: [
72+
# { field: "id", path: "name" }
73+
# { field: "fullName", path: "value.fullName" }
74+
# { field: "age", path: "value.age" }
75+
# ]
6976
)
7077
}

0 commit comments

Comments
 (0)