How to implement User Defined Function using createAccount API

In the previous post, we have seen implementing User defined functions using delete API.

Let’s check how to use the createAccount API to create an account using the User Defined Function.

Example

Here is a createStudentAccount function to create a Student account. It uses the createAccount API to create a student Account.

type Mutation {
 createStudentAccount( value: AccountInput! ): Hypi @tan(type:Groovy, inline: """return createAccount(value)""")
}

Let’s execute the function!

mutation {
 createStudentAccount(
     value: {
         username: "low-code"
         password: { value: "low-code@hypi.io" }
         emails: [{ value: "low-code@hypi.io" }]
     }
     ) {
         id
         created
         createdBy
     }
}
#result
{
  "data": {
    "createStudentAccount": {
      "id": "01F9V9JVG571TCQ11KSM7Y5PR5",
      "created": "2021-31-12T12:16:44Z",
      "createdBy": "01F9V9JVG571TCQ11KSM7Y5PR5"
    }
  }
}