You can create custom functions out of your company’s existing API endpoints or graphQL mutations. This can be used to extend Internal’s functionality and allow it to work with any other system with available APIs.
Click on Company Settings → Data Sources. Click on the HTTP data source you connected; this should contain your API endpoint(s) or graphQL mutation(s).
In the “Functions” section, click “Add New”. (Once you have existing functions, click “View” to browse and edit the functions in your Function Library.)
First, name your function (such as "Update User", "Send Message"). This function name is shown when you select an action for your component to perform.
Path: Specify your API endpoint/graphQL URL.
Method: Select the method for your HTTP request (GET, HEAD, POST, PUT, PATCH, DELETE)
URL Parameters: Add parameters to be passed along within the URL.
Headers: You can add additional key-value pairs to be passed along in the request header when this function is used. Just like URL parameters, you can use JS template literals in both the Key and Value inputs.
If you also defined key-value pairs when you connected the HTTP data source header, any pairs defined here would be passed along in addition to those defined in the data source. If there are conflicting values for the same key, the value defined for the function will win (over the value from the data source).
Once you’re done setting up your function, hit Save. It will be added to your Function Library, and you’ll be able to use these functions in Spaces by attaching them to components like buttons, forms, and pop-up forms.
See the screenshots below for another example of reducers, as well as the reduced vs. untransformed output.
GraphQL Notes: Query variables apply to mutations (that change data). A GraphQL query can be used to create an internal function that solely reads data. In order to display what is returned by a read function, you need to use the JSON viewer component.