Functions
Function implement logic of Membrane Interfaces.
Think of functions as pieces of code that run inside Membrane and have access to the current customer, API credentials, and other integrations-related context.
In many cases functions are pieces of Javascript/Typescript code that looks like this:
module.exports = async function(args) {
console.log('I am a log')
retunr 'I am function output'
}
Besides JavaScript, there are many possible function types that are typically defined in YAML. They are created to simplify the integration logic as much as possible and reduce the possibility of errors, especially when generated by AI.
Function Types
Functions can be implemented in one of the following ways depending on where the function is used:
Core Implementation Function Types
- Mapping – Transform input data using JSONata expressions without making API calls
- REST API Mapping – Map to REST API endpoints
- JavaScript – Write custom code for maximum flexibility
- GraphQL API Mapping – Map to GraphQL API endpoints
Data Collection Action Function Types
- list-data-records – List records in a data collection page by page
- find-data-record-by-id – Find a record in a data collection by ID
- search-data-record – Search data records by a query string
- match-data-record – Find a data record with fields matching a query
- create-data-record – Create a new data record
- update-data-record – Update an existing data record
- delete-data-record – Delete a data record by id
API Request Action Function Types
- api-request-to-external-app – Make API requests to the external service
- api-request-to-your-app – Make API requests to your internal API
- http-request – Make arbitrary HTTP requests to any endpoint
Code Execution Action Function Types
- JavaScript – Run custom JavaScript/TypeScript code (includes
run-javascript
action type)
Flow Node Function Types
- run-action – Run predefined actions
Special Function Types
not-supported
– Mark function as not supported by the external API
Updated 12 days ago