How to register new user accounts in your lowcode Hypi app instance

Creating user accounts is an essential step in authenticating users in any data-driven application.

Let’s see how to create user accounts in an instance on the Hypi domain.

  • There is an in-built Account data type that holds the user’s profile.
  • Account is a part of system apps called Core.
  • createAccount is the API to create the user account.

createAccount(value: AccountInput!): Hypi

  • The function returns the account id, the date of creation, and created by information from the created Account object.
  • The user accounts created under an instance are not accessible on another instance.

Sample Query

mutation {
 createAccount(
     value: {
         username: "test"
         password: { value: "[email protected]" }
         emails: [{ value: "[email protected]" }]
     }
     ) {
         id
         created
         createdBy
     }
}
#Result
{
  "data": {
    "createAccount": {
      "id": "01FG4EYZ7MNB00VPRHFTRTAYE1",
      "created": "2021-09-21T15:18:05Z",
      "createdBy": "01FG4EYZ7MNB00VPRHFTRTAYE1"
    }
  }
}

Query with Variables

mutation CreateAccount($values: AccountInput!) {
    createAccount(value: $values) {
      id
      created
      createdBy
    }
  }
# Variables
{
  "values": {
      "username": "hypi-user",
      "password": { "value": "[email protected]" },
      "emails": [{ "value": "[email protected]" }],
      "owner": {
        "dob": "1983-12-3",
        "gender": "MALE",
        "names": [
          { "title": "Mr", "firstName": "hypi-user", "lastName": "hypi-profile" }
        ],
        "addresses": [
          {
            "door": "172",
            "street": "83",
            "town": "MIHAN",
            "city": "Nagpur",
            "country": { "hypi": {"id": "INDIA" }, "name": "INDIA" },
            "postCode": "444444"
          }
        ]
      },
      "phones": [{ "number": "9765432679", "code": "+91" }]
    }
}

Note: For simplicity, use the country name as the hypi.id.

Data Types

type Account {
  hypi: Hypi
  verified: Boolean
  enabled: Boolean
  username: String!
  password: Password!
  owner: Person
  emails(…): [Email!]
  phones(…): [Phone!]
  roles(…): [Role!]
 }

The Account object also keeps the information whether the user has been authenticated using the Boolean fields verified and enabled. By default, the account gets enabled. Before verification, the verified field has false status. After verification of the user details, you may change the status to true by updating the Account object using the upsert function.

type Person {
hypi: Hypi
dob: DateTime
gender: Gender
avatar: Image
names(...): [PersonName!]!
addresses(...): [Address!]
phones(...): [Phone!]
roles(...): [Pair!]
preferences(...): [Pair!]
}
type Address {
hypi: Hypi
door: String
street: String
town: String
county: String
city: String
country: Country
postCode: String
from: DateTime
to: DateTime
}

You may check other data types under Dependencies in the core table.

Check the POSTMAN collection for the account creation requests in different programming languages! Click </> and choose the programming language of your choice.

Don’t forget to insert your own Authorization key and Hypi Domain under Headers to test the results!

Run in Postman