Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
.env
.env
.vscode

2 changes: 1 addition & 1 deletion transforms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ For more on what `transforms` is and how it operates within the custom `@rest` d

- [filter](filter) shows how the response of a REST API can be filtered
- [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)
- [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
- [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
- [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.
11 changes: 9 additions & 2 deletions transforms/jsonobjectToJsonarray/api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ type Query {
# you could comment this out if you want to try setters instead
{
pathpattern: ["[]*"]
editor: "jq:.[]|{id:.name,fullName:.value.name,age:.value.age}"
editor: "jq:.[]|{id:.name,fullName:.value.fullName,age:.value.age}"
}
]

# for the second transformation, you can use setters. Uncomment the next line and comment the second pathpattern line above to see how it operates.
# setters: [{field: "id", path: "name"}, {field:"fullName", path: "value.age"}, {field:"age", path:"value.fullName"}]
# In order to make this to work, change the return type from JSON to [Customer].

# setters: [
# { field: "id", path: "name" }
# { field: "fullName", path: "value.fullName" }
# { field: "age", path: "value.age" }
# ]
)
}