Open
Description
I try to set up mesh for getting data from a service. The service has specific interface. I have no way to change the interface.
The service uses only POST requests to get and update data. All parameters for every method should be passed as an array in a request body.
Example
const accountId = 1;
const filter = {active: true}
const body = [accountId, filter];
fetch('/get/users', { method: 'POST', body });
When I try to setup it in json-schema
I need to use requestSample
in handler.operations. But it takes just object and if I set an array there the handler takes just first argument and ignore other.
What do you think about an opportunity to transform body before request. It can be a path to file like additionalResolvers
operations:
- type: Query
field: account
path: /AccountsResource/getUsersByFilter
method: POST
requestSample: ./json-samples/account-input.json
responseSchema: ./json-schemas/account.json#/definitions/Account
# this is new option
bodyTransform: ./json-transforms/account
requestSample can be like this
{
"accountId": 1,
"filter": {
"active": true
}
}
And this is transform example
// account-input.json
module.exports = {
transform: (body) => {
const { accountId, filter } = body;
return [accountId, filter];
}
}
It should work fine.
Metadata
Metadata
Assignees
Labels
No labels