Skip to main content

Handling query parameters

Parameters in functions

It is possible to pass parameters to functions. This is done through the following syntax:

hello(name: string) := {
"Hello "+name+"!"
};

Arguments can have default values:

hello(name: string := "Anonymous") := {
"Hello "+name+"!"
};

and can also be nullable:

hello(name: string null) := {
"Hello "+name+"!"
};

This allows name to be null. Without this, if you pass null to a non-nullable argument, the function will return null.
And you can combine default and nullable.

hello(name: string null:= "Anonymous") := {
"Hello "+name+"!"
};

This one allows ommiting the parameter (will take the default value) and null parameter.

Endpoint query parameters

Published endpoints are mapped to functions.
The function declaration will determine the endpoint behavior regarding parameters, the rules applying to the function will apply similarly to endpoints. For instance:

// Mandatory => .../hello?name="Joe"
hello(name: string) := {...};

// Optionnal => .../hello (will use "Anonymous") or .../hello?name="Joe"
hello(name: string := "Anonymous") := {...};

// Optionnal => .../hello (will use null) or .../hello?name="Joe"
hello(name: string null) := {...};