The Directual API-builder provides lots of additional configure options which are really useful for professional front-end developers. Let’s take a look at them!
The Directual database can store millions of objects, so it probably wouldn’t be a very efficient solution to grab them all from one request because that would be very time-consuming. The best, and most common practice to achieve that is to organise paging or dynamic content loading at the front-end.
For that, Directual supports special parameters pageSize that’s how many objects you want in the response, and ‘page’, which is simply the number of the page you’ve requested.
We looked at sorting settings in "The basics" tutorial but sometime, you’ll need dynamic sorting. For example, if a user sets up sorting in the app interface. To handle that Directual supports special parameters in GET-requests. The parameter is called sort. The value is a combination of a field’s system name and a sorting order. We can use several sorting fields, one by one.
A GET-request can contain any number of custom parameters and, by composing filtering conditionals, we can include these parameters by typing {{HttpRequest.parameter_system_name}}.
In some cases, a developer needs to set up rather complex filtering. Simple lists of logical ‘AND’ and logical ‘OR’ are not enough. We need to combine different expressions. We can switch the conditional editor to coding-mode and describe any filtering logic in JSON-format. Like this.
You’ll find more detailed examples in the documentation.
It’s good practice for the API-layer to validate data on-the-go and respond with an exception if validation fails. The rules for each field from the security layer can be configured in api-endpoint settings. Note that if we try to POST a wrong object, we’ll see an exception in response.
A regular POST-request sends for an object and in response receives the status and the object. If there are scenarios that process all new objects of a certain type, they will normally run independently after the request has been received.
But there is another option. We can include a scenario (or a few of them) in the “running synchronically” list for our request. In this case the response will be sent AFTER the sync-mode-scenario has been completed.
It works like this:
If a developer needs to request the API-endpoint from different domains, the cross-origin resource sharing option should be ON.
Have questions? Visit our facebook group.