@id and @hasinverse on specific type

Hi there @lzr , welcome to the Dgraph community!

I noticed something strange about your schema: you have TWO @hasInverses .

Based on what you want to do, the following schema is more than enough:

type Account {
    email: String! @id @search(by: [hash, regexp])
    sessions: [Session] @hasInverse(field: account)
}

type Session {
    id: ID!
    account: Account! # THIS WAS REMOVED.
    mail_to: String! @search(by: [hash, regexp])
    mail_from: String! @search(by: [hash, regexp])
    mail_text: String!
    mail_html: String!
    mail_subject: String! @search(by: [hash, regexp])
    mail_original: String!
}

Now on to your questions:

It’s normal.

That’s funny. That shouldn’t happen. I will try to reproduce based on your queries/code

I noticed you used expand(_all_). That function only expands terminal nodes. To get the sessions, you need to do this:

{
  node(func: type(Account)) @recurse(depth:3){
    uid
    expand(_all_)
    Account.sessions {}
  }
}