After the creation of the serverless function on the Hypi namespace, now is the time to use it!
Before you start using the serverless function, you need to define a GraphQL type (Query/Mutation) in the schema like this.
f1 has been defined with input parameters
band it returns a JSON value. It uses @tan directive to access serverless function
hithere (Check this guide on how to create serverless function).
@tan directive has the following structure.
|type||OpenWhisk type is used for serverless functions. Groovy/Velocity type is used with User Defined Functions||Groovy/Velocity/OpenWhisk|
|name||The name of the serverless function in the docker image OR if it is a script, the script's name.Required IFF the "inline" parameter isn't provided.||hithere|
|inline||Instead of the name of an existing function, short scripts can be provided inline with this field. If name is provided, this is ignored. If this is not provided, name MUST be present. The value of this field is the contents of the script in one of the supported tan script types.|
|saveAs||If present, the result of the function will be stored in Hypi as the given type. The type must exist in the current instance.|
It is now time to run the function and pass some real values and obtain the results. Use a query like this.
- GraphQL Query