How to save Email details

In the previous post, we have seen the creation of Counter.

In this post, we will save Email details using using an inbuilt data type.

Email type saves the email details. Check Core app that includes Email data type.

Email data type stores Email details of an account. It provides an internal validation check for the Email format.

Let’s save the email details using upsert mutation.

mutation {
  upsert(values: { Email: [{ value: "asa@hypi.io", type: "Personal" }] }) {
    id
  }
}
#result
{
  "data": {
    "upsert": [
      {
        "id": "01geex7822jq87pc7we2cybjxd"
      }
    ]
  }
}

You can get the email details using hypi.id.

{
  get(type: Email, id: "01geex7822jq87pc7we2cybjxd") {
    ... on Email {
      hypi {
        id
        created
        updated
      }
      value
      type
    }
  }
}
#result
{
  "data": {
    "get": {
      "hypi": {
        "id": "01geex7822jq87pc7we2cybjxd",
        "created": "2022-10-03T12:30:35Z",
        "updated": "2022-10-03T12:30:35Z"
      },
      "value": "asa@hypi.io",
      "type": "Personal"
    }
  }
}