#12. Select
Now let's turn on our first opt-in feature: field selection.
#Start the demo server
telepact demo-server --port 8000#Find the internal @select_ header
curl -s localhost:8000/api -d '[{}, {"fn.api_": {"includeInternal!": true}}]'The schema entry looks like this:
{
"headers.Select_": {
"@select_": "_ext.Select_"
},
"->": {}
}For the full rule set, see the _ext.Select_ guide.
#Compare a full response with a selected response
Full response:
curl -s localhost:8000/api -d '[{}, {"fn.evaluate": {"expression": {"Add": {"left": {"Constant": {"value": 2}}, "right": {"Constant": {"value": 3}}}}}}]'[{}, {"Ok_": {"result": 5, "saveResult": {"fn.saveVariable": {"name": "result", "value": 5}}}}]Selected response:
curl -s localhost:8000/api -d '[{"@select_": {"->": {"Ok_": ["result"]}}}, {"fn.evaluate": {"expression": {"Add": {"left": {"Constant": {"value": 2}}, "right": {"Constant": {"value": 3}}}}}}]'[{}, {"Ok_": {"result": 5}}]Nothing about the function changed. We just told the server which response fields we wanted back.
@select_ always uses the same shape:
->selects fields on the active result unionstruct.*selects fields on reachable structsunion.*selects fields for reachable union tags
Next: 13. Binary