diff --git a/.gitignore b/.gitignore index 1dcef2d..a377996 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules -.env \ No newline at end of file +.env +.vscode + diff --git a/transforms/README.md b/transforms/README.md index ec4f038..527c673 100644 --- a/transforms/README.md +++ b/transforms/README.md @@ -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. diff --git a/transforms/jsonobjectToJsonarray/api.graphql b/transforms/jsonobjectToJsonarray/api.graphql index 763a5bf..7e71d44 100644 --- a/transforms/jsonobjectToJsonarray/api.graphql +++ b/transforms/jsonobjectToJsonarray/api.graphql @@ -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" } + # ] ) }